Add code integrity verification
This commit is contained in:
parent
213f23977f
commit
ae2b9d47ed
|
@ -152,6 +152,29 @@ def connectionHandle(client_socket, client_address):
|
|||
server_socket.close()
|
||||
client_socket.close()
|
||||
|
||||
def verify_code_integrity():
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
content = None
|
||||
md5_hash = None
|
||||
|
||||
with open(sys.argv[0], 'rb') as f:
|
||||
content = f.read()
|
||||
|
||||
with open('proxy.py.md5', 'r') as f:
|
||||
md5_hash = f.read()
|
||||
|
||||
hash = hashlib.md5(content).hexdigest()
|
||||
|
||||
if hash != md5_hash:
|
||||
print('ERROR: proxy.py has been tampered with!')
|
||||
exit(1)
|
||||
|
||||
print('[Code Integrity] proxy.py is verified!')
|
||||
|
||||
if __name__ == '__main__':
|
||||
verify_code_integrity()
|
||||
|
||||
ser = Server(host="0.0.0.0", port=8080)
|
||||
ser.start()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
24d2be62b48be63f31093585f52f7887
|
Loading…
Reference in New Issue