Add utils.
This commit is contained in:
parent
ffc5103dac
commit
9a6edf0020
|
@ -0,0 +1,19 @@
|
|||
import socket
|
||||
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
|
||||
|
||||
def unix_time(dt):
|
||||
epoch = datetime.utcfromtimestamp(0)
|
||||
delta = dt - epoch
|
||||
return delta.total_seconds()
|
||||
|
||||
|
||||
def netcat(hostname, port, content):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect((hostname, port))
|
||||
s.sendall(content)
|
||||
sleep(0.005)
|
||||
s.shutdown(socket.SHUT_WR)
|
||||
s.close()
|
Reference in New Issue