0

我用 Python 做了一个简单的 TCP fuzzer。我需要它能够接收到一些响应,如果我没有得到响应,请打破循环。我的代码是这样的:

import socket
from time import sleep
import sys

ip = raw_input ("please insert host ip: ")
port = input ("please insert port to fuzz: ")
packet = raw_input ("what string would you like to fuzz with? :  ")
multi = input ("in what jumps would you liike to multiply the string ? (10 = A*10) : ")
host = ip, port
s = socket.socket()
char = packet * multi
a = 1

try:
    while a > 0:
        s.connect((host))
        s.send(packet)
        sleep(1) 
        print 'fuzzing param %s' % (packet)
        packet = char + packet 
        s.close()
except (Exception):
    print "Connection lost for some reason"'

但是当我运行程序时,我得到了这个错误:

please insert host ip: 10.0.0.138
please insert port to fuzz: 80
what string would you like to fuzz with? :  A
in what jumps would you liike to multiply the string ? (10 = A*10) : 2
fuzzing param A
Connection lost

这很奇怪,因为它只是假设在无限循环中重新连接,(我知道服务器没有崩溃)

4

2 回答 2

2

远程端点只是挂断了,可能是因为您发送的数据与它期望的格式不匹配。

您可以在每次远端挂断时创建一个新连接,或者以远端期望的格式发送数据。例如,如果远程端是 HTTP 服务器,您可能希望先发送请求行,然后再发送模糊部分,如下所示:

GET / HTTP/1.0
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
于 2012-07-15T10:41:55.087 回答
1

当您进行模糊测试时(通常情况下),处理错误非常重要。当您将 Gibberish 发送到您的服务器时,您应该预料到会出现问题。所以我建议你用try... except...finally: s.close()子句包装电话。并打印调试消息以查看您何时发送失败并开始查看原因 - 您不知道服务器对您发送的内容有何反应,并且您可能在第一次调用后就杀死了服务器......

于 2012-07-15T11:16:21.017 回答