Skip to content

Instantly share code, notes, and snippets.

View carcigenicate's full-sized avatar

carcigenicate

View GitHub Profile

I admit this is doesn't actually answer your question, but it may be a better way of approaching this problem.

. . .SimpleNamespace is commonly used as alternative to tuple in which data members are named

But, the docs of SimpleNamespace note:

Unlike object, with SimpleNamespace you can add and remove attributes.

Which doesn't align with how tuples behave. I think a [NamedTuple][1] would be more appropriate here:

from binascii import hexlify, unhexlify
from typing import Optional, List, Any, Union, Iterable, Tuple
import random
from string import ascii_letters
from multiprocessing.pool import ThreadPool
from collections import Counter
from scapy.arch import get_if_hwaddr, get_if_raw_hwaddr, NetworkInterface, dev_from_index
from scapy.config import conf
from scapy.layers.dhcp import DHCP, BOOTP
from multiprocessing import Process
def func():
print("Ran")
print("Outer")
if __name__ == "__main__":
p = Process(target=func)
p.start()
#!/usr/bin/env python
# Prints the temperature in celcius of the Raspberry Pi
try:
with open("/sys/class/thermal/thermal_zone0/temp", "r") as f:
huge_celcius = int(f.read())
print huge_celcius / 1000.0, "C"
except (ValueError, OSError) as e:
print "Cannot read temperature: ", e
def my_zip(*iterables):
iters = [iter(i) for i in iterables]
while True:
try:
yield tuple([next(it) for it in iters])
except StopIteration:
return
from multiprocessing.pool import ThreadPool
import socket
from time import perf_counter
def run(ip, port): # Pass directly to run
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.settimeout(1)
sock.connect((ip, port))
def a():
return 5
def b():
return a()
def c():
return b()
c()
from scapy.layers.inet import IP, ICMP
from scapy.sendrecv import sr1
from typing import Iterable, Tuple, Optional
MAX_TTL = 255
DEFAULT_TIMEOUT = 5
DEFAULT_VERBOSITY = False
from multiprocessing import Process
from scapy.all import *
def sniff_target():
sniff(iface=dev_from_index(20), prn=shellreply, filter="icmp", store="0")
def shellreply(pkt):
print("Reply:", pkt)
from scapy.config import conf
from scapy.layers.l2 import ARP
from scapy.arch import get_if_hwaddr
def _new_unsolicited_reply_redirect(victim_ip: str,
redirect_from_ip: str,
redirect_to_mac: Optional[str] = None) -> ARP:
mac = redirect_to_mac or get_if_hwaddr(conf.iface)
return ARP(hwsrc=mac, psrc=redirect_from_ip, pdst=victim_ip, op="is-at")