This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scapy.all import * | |
from scapy.packet import * | |
import threading | |
from time import sleep | |
def getmac(targetip): | |
arppacket = Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(op=1, pdst=targetip) | |
try: | |
targetmac = srp(arppacket, timeout=3, verbose=False)[0][0][1].hwsrc | |
except: | |
targetmac = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bulk_upsert(model, fields, values, by): | |
""" | |
Return the tuple of (inserted, updated) ids | |
""" | |
result = (None, None) | |
if values: | |
stmt = """ | |
WITH data_set AS ( | |
INSERT INTO %s (%s) |