Last active
March 30, 2019 19:24
-
-
Save huyhoang8398/b4b466ca05a4f745768bd1e159ab6594 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import socket | |
import time | |
ETH_P_ALL = 3 | |
interface = 'lo' | |
dst = b'\x08\x00\x27\xdd\xd7\x43' # destination MAC address | |
src = b'\x08\x00\x27\x8e\x75\x44' # source MAC address | |
proto = b'\x88\xb5' # ethernet frame type | |
# print (payload) | |
# while True: | |
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL)) | |
s.bind((interface, 0)) | |
payload = input() | |
while payload != 'q': | |
command = ('command'+payload).encode() | |
print (command) | |
s.sendall(dst + src + proto + command) | |
data = s.recv(1514) | |
data = s.recv(1514) | |
dataParse = str(data[14:]) | |
# print (dataParse) | |
# print (dataParse) | |
if dataParse.find('output'): | |
dataParseN = dataParse.decode() | |
# output = dataParse.replace('output', '') | |
print (dataParseN) | |
# print (data) | |
payload = input() | |
# s.Nsendall(payload) | |
s.close() | |
# time.sleep(0.9) | |
# print ('gui ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment