<commit_before>#!/usr/bin/env python2

import requests
import argparse
#import re

parser = argparse.ArgumentParser(description='SOAP web service Fuzzer')
parser.add_argument("url", help="Web service URL to fuzz")
args = parser.parse_args()

#args.url = args.url.lower()  
#url = args.url;

def end( reason ):
    print reason;
    exit();

def check_url( url ):
if ((url.find('http://',0,7) == -1) and (url.find('https://',0,8) == -1)):
    end('\nERROR: not starting with http or https.\nCheck your URL and try again.\n');


check_url( args.url )

print('Checking if URL is available:\n');
r = requests.post(url, data=, headers=)   <commit_msg>finished adding web connectivity; request response will now be saved to disk<commit_after>#!/usr/bin/env python2

import requests
import argparse
import json
import os
from datetime import datetime

parser = argparse.ArgumentParser(description='SOAP web service Fuzzer', fromfile_prefix_chars='@')
parser.add_argument('url', help='Web service URL to fuzz')
parser.add_argument('--header', nargs='*', help='Specify required request headers')
parser.add_argument('--data', help='Data to be sent inside the request body')
args = parser.parse_args()

#args.url = args.url.lower()  
#url = args.url;
path = 'requests/';     # path to write requests's response

def end( reason ):
    print reason;
    exit();

def check_url_syntax( url ):
    if ((url.find('http://',0,7) == -1) and (url.find('https://',0,8) == -1)):
        end('\nERROR: not starting with http or https.\nCheck your URL and try again.\n');

def verify_url( url ):
    print('\nChecking if URL is available...');
    req = requests.post(url, data='');   
    if (req.status_code == requests.codes.ok):
        print 'OK\n';
        return
    else:
        print "HTTP Response Status Code %s - %s" %(req.status_code, req.reason);
        end("Exiting.\n");


def make_request( url, http_headers={'Content-Type': 'text/xml; charset=utf-8', 'User-Agent': 'FuzzML/1.0'}, content='None' ):
    http = requests.post( url, data=content, headers=http_headers );
    return http;

def get_address( url ):
    if url.startswith('http://'):
        address = url.replace('http://', '', 1);
        address = address.replace('/', '_');
        time = datetime.now();
        address = address + '_' + time.strftime("%Y%m%d_%H%M.%S.%f") + '.txt';    # www.example.com_webservice.php_20141110_1822.15.059238.txt
        return address;
    elif url.startswith('https://'):
        address = url.replace('https://', '', 1);
        address = address.replace('/', '_');
        time = datetime.now();
        address = address + '_' + time.strftime("%Y%m%d_%H%M.%S.%f") + '.txt';    # www.example.com_webservice.php_20141110_1822.15.059238.txt
        return address;
    else:
        end('Malformed URL');


check_url_syntax( args.url );
verify_url( args.url );
url = get_address( args.url ); 
http_resp = make_request( args.url, args.header, args.data );
http_resp.close();

if not os.path.exists(path):
    os.makedirs(path);

fp = open(path + url, 'w+');    # requests/www.example.com_webservice.php_20141110_1822.15.059238.txt
fp.write(http_resp.text);


{'fraction_non_alphanumeric': 0.17300380228136883, 'fraction_numerical': 0.025031685678073512, 'mean_word_length': 3.568740955137482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 3, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7403466', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1047, 'n_words': 260}