|
19 | 19 | ssl._create_default_https_context = ssl._create_unverified_context |
20 | 20 |
|
21 | 21 |
|
| 22 | +def save_to(savePath, vulnAddrs, possAddrs, strTbAttack,intTbAttack): |
| 23 | + fo = open(savePath, "wb") |
| 24 | + fo.write ("Vulnerable URLs:\n") |
| 25 | + fo.write("\n".join(vulnAddrs)) |
| 26 | + fo.write("\n\n") |
| 27 | + fo.write("Possibly Vulnerable URLs:\n") |
| 28 | + fo.write("\n".join(possAddrs)) |
| 29 | + fo.write("\n") |
| 30 | + fo.write("Timing based attacks:\n") |
| 31 | + |
| 32 | + if strTbAttack == True: |
| 33 | + fo.write("String Attack-Successful\n") |
| 34 | + else: |
| 35 | + fo.write("String Attack-Unsuccessful\n") |
| 36 | + fo.write("\n") |
| 37 | + |
| 38 | + if intTbAttack == True: |
| 39 | + fo.write("Integer attack-Successful\n") |
| 40 | + else: |
| 41 | + fo.write("Integer attack-Unsuccessful\n") |
| 42 | + fo.write("\n") |
| 43 | + fo.close() |
| 44 | + |
22 | 45 | def args(): |
23 | 46 | return [ |
| 47 | + ["--injectedParameter", "Parameter to be injected"], |
24 | 48 | ["--injectSize", "Size of payload"], |
25 | 49 | ["--injectFormat", "1-Alphanumeric, 2-Letters only, 3-Numbers only, 4-Email address"], |
26 | 50 | ["--params", "Enter parameters to inject in a comma separated list"], |
27 | | - ["--doTimeAttack", "Start timing based tests (y/n)"]] |
| 51 | + ["--doTimeAttack", "Start timing based tests (y/n)"], |
| 52 | + ["--savePath", "output file name"]] |
28 | 53 |
|
29 | 54 | def getApps(webPort,victim,uri,https,verb,requestHeaders, args = None): |
30 | 55 | print "Web App Attacks (GET)" |
@@ -75,7 +100,6 @@ def getApps(webPort,victim,uri,https,verb,requestHeaders, args = None): |
75 | 100 |
|
76 | 101 | if verb == "ON": |
77 | 102 | print "App is up! Got response length of " + str(normLength) + " and response time of " + str(timeBase) + " seconds. Starting injection test.\n" |
78 | | - |
79 | 103 | else: |
80 | 104 | print "App is up!" |
81 | 105 | appUp = True |
@@ -342,31 +366,14 @@ def getApps(webPort,victim,uri,https,verb,requestHeaders, args = None): |
342 | 366 | if args == None: |
343 | 367 | fileOut = raw_input("Save results to file (y/n)? ") |
344 | 368 | else: |
345 | | - fileOut = "n" |
| 369 | + fileOut = "y" if args.savePath else "n" |
346 | 370 |
|
347 | 371 | if fileOut.lower() == "y": |
348 | | - savePath = raw_input("Enter output file name: ") |
349 | | - fo = open(savePath, "wb") |
350 | | - fo.write ("Vulnerable URLs:\n") |
351 | | - fo.write("\n".join(vulnAddrs)) |
352 | | - fo.write("\n\n") |
353 | | - fo.write("Possibly Vulnerable URLs:\n") |
354 | | - fo.write("\n".join(possAddrs)) |
355 | | - fo.write("\n") |
356 | | - fo.write("Timing based attacks:\n") |
357 | | - |
358 | | - if strTbAttack == True: |
359 | | - fo.write("String Attack-Successful\n") |
360 | | - else: |
361 | | - fo.write("String Attack-Unsuccessful\n") |
362 | | - fo.write("\n") |
363 | | - |
364 | | - if intTbAttack == True: |
365 | | - fo.write("Integer attack-Successful\n") |
| 372 | + if args == None: |
| 373 | + savePath = raw_input("Enter output file name: ") |
366 | 374 | else: |
367 | | - fo.write("Integer attack-Unsuccessful\n") |
368 | | - fo.write("\n") |
369 | | - fo.close() |
| 375 | + savePath = args.savePath |
| 376 | + save_to(savePath, vulnAddrs, possAddrs, strTbAttack,intTbAttack) |
370 | 377 |
|
371 | 378 | if args == None: |
372 | 379 | raw_input("Press enter to continue...") |
@@ -450,10 +457,10 @@ def postApps(victim,webPort,uri,https,verb,postData,requestHeaders): |
450 | 457 | menuItem += 1 |
451 | 458 |
|
452 | 459 | try: |
453 | | - injIndex = 1 |
454 | 460 | if args == None: |
455 | 461 | injIndex = raw_input("Which parameter should we inject? ") |
456 | | - |
| 462 | + else: |
| 463 | + injIndex = int(args.injectedParameter) |
457 | 464 | injOpt = str(postData.keys()[int(injIndex)-1]) |
458 | 465 | print "Injecting the " + injOpt + " parameter..." |
459 | 466 | except: |
@@ -729,31 +736,17 @@ def postApps(victim,webPort,uri,https,verb,postData,requestHeaders): |
729 | 736 | else: |
730 | 737 | print "Integer attack-Unsuccessful" |
731 | 738 |
|
732 | | - fileOut = raw_input("Save results to file (y/n)? ") |
| 739 | + if args == None: |
| 740 | + fileOut = raw_input("Save results to file (y/n)? ") |
| 741 | + else: |
| 742 | + fileOut = "y" if args.savePath else "n" |
733 | 743 |
|
734 | 744 | if fileOut.lower() == "y": |
735 | | - savePath = raw_input("Enter output file name: ") |
736 | | - fo = open(savePath, "wb") |
737 | | - fo.write ("Vulnerable Requests:\n") |
738 | | - fo.write("\n".join(vulnAddrs)) |
739 | | - fo.write("\n\n") |
740 | | - fo.write("Possibly Vulnerable Requests:\n") |
741 | | - fo.write("\n".join(possAddrs)) |
742 | | - fo.write("\n") |
743 | | - fo.write("Timing based attacks:\n") |
744 | | - |
745 | | - if strTbAttack == True: |
746 | | - fo.write("String Attack-Successful\n") |
747 | | - else: |
748 | | - fo.write("String Attack-Unsuccessful\n") |
749 | | - fo.write("\n") |
750 | | - |
751 | | - if intTbAttack == True: |
752 | | - fo.write("Integer attack-Successful\n") |
| 745 | + if args == None: |
| 746 | + savePath = raw_input("Enter output file name: ") |
753 | 747 | else: |
754 | | - fo.write("Integer attack-Unsuccessful\n") |
755 | | - fo.write("\n") |
756 | | - fo.close() |
| 748 | + savePath = args.savePath |
| 749 | + save_to(savePath, vulnAddrs, possAddrs, strTbAttack,intTbAttack) |
757 | 750 |
|
758 | 751 | raw_input("Press enter to continue...") |
759 | 752 | return() |
|
0 commit comments