コード例 #1
0
def main():
    client, sock = makeSock()
    sizeAndTests = client.recv(4096)
    fSize = int(sizeAndTests.split(',')[0])
    client.send('c' * 4096)
    resultHash = client.recv(1024)
    #print resultHash
    client.send('c' * 1024)
    path = os.path.join(curPath, "Recieved File", "file.exe")
    f = getFile(path, fSize, client)
    f.close()
    sock.close()
    client.close()

    f = open(path, "rb")

    recievedHash = hashlib.sha256(f.read()).hexdigest()
    #print recievedHash
    if (recievedHash != resultHash):
        print "File not recieved successfully"
        raise Exception("Bad File")

    #resultIsPacked = checkSections(fName)
    #print resultIsPacked
    f.close()
    entropy(path)

    if upx.isUPX(path):
        print "Packed with UPX"
        print "Unpacking..."
        try:
            upx.unpackUPX(path)
        except Exception, e:
            print "Unpacking error:", e
            return False
        print "Unpacked!"