1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Scapy - persistent RandIP

Discussão em 'Python' iniciado por Stack, Setembro 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to simulate a TCP communication between two hosts with scapy.

    My problem is, that I can't save the random IP addresses scapy generates for me.

    This code

    src_IP = RandIP()

    print(src_IP)
    print(src_IP)
    print(src_IP)


    gives me an output like this

    234.200.98.20
    147.3.56.17
    135.102.142.49


    So every time I access src_IP it has a new value.

    Is there a way to save a random IP from scapy? So I could generated 2 IPs at the beginning of my function and use them as source and destination for my TCP communication.
    I could generate the IPs myself, but I thought there had to be a more elegant solution to it.

    BTW. non of the packets are going to be sent, they will be written into a PCAP file. Therefor I have to create both sides of the communication.

    Continue reading...

Compartilhe esta Página