[python] 0x3 Python Tutorial: Fuzzer
2015-09-16 14:03
323 查看
Fuzzer的作用就是发送不同数量的输入,尝试使得应用程序崩溃。
首先看一个fuzzer的伪代码
下面的代码是测试ftp的
程序的运行过程如下:
首先看一个fuzzer的伪代码
<import modules> #most likely will be socket, sys, but if its a web service you might import httplib,urllib,etc. #Set up remote IP/Port variables #Invoke the script: ./script.py <RHOST> <RPORT> RHOST = sys.argv[1] RPORT = sys.argv[2] #Define your buffer string that will be incremented and send the buffer buffer = '\x41'*50 #Create a loop that will connect to the service and send the buffer: while True: try: #send buffer #increment buffer by 50 buffer = buffer + '\x41'*50 except: print "Buffer Length: "+len(buffer) print "Can't connect to service...check debugger for potential crash"
下面的代码是测试ftp的
#Import the required modules the script will leverage #This lets us use the functions in the modules instead of writing the code from scratch import sys,socket from time import sleep #set first argument given at CLI to 'target' variable target = sys.argv[1] #create string of 50 A's '\x41' buff = '\x41'*50 # loop through sending in a buffer with an increasing length by 50 A's while True: #The "try-except" catches the programs error and takes our defined action try: # Make a connection to atrget system on TCP/21 s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.settimeout(10) s.connect((target,21)) s.recv(1024) print "Sending buffer with length: "+str(len(buff)) #Send in string 'USER' + the string 'buff' s.send("USER "+buff+"\r\n") s.close() sleep(1) #Increase the buff string bu 50 A's and then the loop continues buff = buff + '\x41'*50 except:#If we fail to connect to the server,we assume its crashed and print the statement below print "[+] Crash occured with buffer length: "+str(len(buff)-50) sys.exit()
程序的运行过程如下:
相关文章推荐
- selenium-webdriver(python) (十六) --unittest 框架
- selenium-webdriver(python) (十五) -- 鼠标事件
- selenium-webdriver(python) (十四) -- webdriver原理
- selenium-webdriver(python) (十三) -- cookie处理
- 轻松自动化---selenium-webdriver(python) (十二)
- python pip安装 PIL
- 轻松自动化---selenium-webdriver(python) (十一)
- 轻松自动化---selenium-webdriver(python) (十)
- python日积月累之isnumeric()
- 轻松自动化---selenium-webdriver(python) (八)
- 轻松自动化---selenium-webdriver(python) (七)
- 轻松自动化---selenium-webdriver(python) (六)
- 轻松自动化---selenium-webdriver(python) (五)
- 轻松自动化---selenium-webdriver(python) (三)
- 深入了解一下PYTHON中关于SOCKETSERVER的模块-D
- 轻松自动化---selenium-webdriver(python) (二)
- 轻松自动化---selenium-webdriver(python) (一)
- 深入了解一下PYTHON中关于SOCKETSERVER的模块-C
- 深入了解一下PYTHON中关于SOCKETSERVER的模块-B
- python的函数嵌套机制