-
Notifications
You must be signed in to change notification settings - Fork 2
/
7ssh.src
151 lines (132 loc) · 5.94 KB
/
7ssh.src
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// NAME: 7ssh (collects all passwd and Bank.txt and libs)
// BUG -> create folder if not exist (only if new installed (folder missing))
// BUG: check if rshell script is there
// Change here values if wanted
pathTemp = "/home/" + active_user + "/Downloads" // temporary place till moved to final desination
pathLib = pathTemp + "/libs" // place where all the libs will be stored
pathCracked = pathTemp + "/cracked" // bank and passwd save place
rshellServer = get_router.public_ip
// Checks
cryptools = include_lib("/lib/crypto.so")
if not cryptools then exit("Error: Missing crypto library")
if params.len < 2 or params.len > 3 then exit("<b>Usage: 7ssh [user@password] [ip address] [(opt) port]</b>")
credentials = params[0].split("@")
remoteHost = params[1]
remoteUsr = credentials[0]
remotePas = credentials[1]
port = 22
if params.len == 3 then port = params[2].to_int
if typeof(port) != "number" then exit("Invalid port: " + port)
// FUNCTIONS
GetPassword=function(userPass)
if userPass.len != 2 then
return null
else
password = cryptools.decipher(userPass[1])
return password
end function
PrintYellowP=function(string)
print("<color=yellow>" + string + "</color>")
end function
PrintWhite=function(string)
print("<color=white>" + string + "</color>")
end function
GetPasswd=function() // crack and store information in a new file
exportFile = "passwd_" + remoteHost // exp: passwd_12.2.3.1
exportFilePath = localComputer.File(pathCracked + "/" + exportFile)
if exportFilePath then exportFilePath.delete // remove in case multiple time run
localComputer.touch(pathCracked, exportFile)
PrintWhite("collecting passwd informations ...")
print("all collected informations will be stored in:\n" + pathCracked + "/" + exportFile)
print("")
file = remoteShell.host_computer.File("/etc/passwd")
listUsers = file.get_content.split("\n")
content = ""
for line in listUsers
userPass = line.split(":")
password = GetPassword(userPass)
if password then
content = localComputer.File(pathCracked + "/" + exportFile).get_content
localComputer.File(pathCracked + "/" + exportFile).set_content(content + char(10) + userPass[0] + ":" + password)
print("user: " + userPass[0] + "\npassword: " + password)
end if
end for
end function
GetBank=function() // crack and store information in single file
folder = remoteShell.host_computer.File("/home")
PrintWhite("collecting bank informations ...")
if not folder.has_permission("r") then
print("permission denied: " + folder.name)
else
homeFolders = folder.get_folders
exportFile = "bank_informations"
exportFilePath = localComputer.File(pathCracked + "/" + exportFile)
contentBank = ""
print("all collected informations will be stored in:\n" + pathCracked + "/" + exportFile)
print("")
for homeFolder in homeFolders
file = remoteShell.host_computer.File("/home/" + homeFolder.name + "/Config/Bank.txt")
if file != null then
if not file then print("Error: file not found")
if not file.has_permission("r") then print("Error: can't read. Permission denied.")
if file.is_binary then print("Error: invalid file found.")
listUsers = file.get_content.split("\n")
for line in listUsers
userPass = line.split(":")
password = GetPassword(userPass)
if password then
if not exportFilePath then localComputer.touch(pathCracked, exportFile)
contentBank = localComputer.File(pathCracked + "/" + exportFile).get_content
localComputer.File(pathCracked + "/" + exportFile).set_content(contentBank + char(10) + userPass[0] + ":" + password)
print("user: " + userPass[0] + "\npassword: " + password + "\n")
end if
end for
end if
end for
end if
end function
GetLibs=function() // download all libs
PrintWhite("collecting /lib informations ...")
folderLib = remoteComputer.File("/lib")
if not folderLib.has_permission("r") then
print("permission denied: " + folderLib.name)
else
libFiles = folderLib.get_files
metaxploit = include_lib("/lib/metaxploit.so")
for libFile in libFiles
libRemote = remoteComputer.File("/lib/" + libFile.name)
remoteShell.scp(libRemote.path, pathTemp, localShell) // DOWNLOAD
metaLib = metaxploit.load(pathTemp + "/" + libFile.name)
libLocal = localComputer.File(pathTemp + "/" + libFile.name)
localComputer.create_folder(pathLib, metaLib.version)
print("file saved: " + pathLib + "/" + metaLib.version + "/" + libFile.name + "\n")
libLocal.move(pathLib + "/" + metaLib.version, libFile.name)
end for
end if
end function
InstallRshell=function() // install and connect rshell on remote
PrintWhite("connecting to rshellserver: " + rshellServer + " ...\n")
localShell.scp("/lib/metaxploit.so", "/lib", remoteShell) // UPLOAD
localShell.scp(pathTemp + "/rshellbackdoor", "/root", remoteShell) // UPLOAD
remoteShell.launch("/root/rshellbackdoor", rshellServer)
fileRemove = remoteComputer.File("/root/rshellbackdoor")
fileRemove.delete
end function
PrintYellowP("running: /bin/7ssh " + remoteUsr + "@" + remotePas + " " + remoteHost + " " + port)
// SSH
print("Connecting to: " + remoteHost + " ...")
localShell = get_shell
localComputer = localShell.host_computer
remoteShell = get_shell.connect_service(remoteHost, port, remoteUsr, remotePas)
remoteComputer = remoteShell.host_computer
if typeof(remoteShell) == "string" then exit(remoteShell)
if not remoteShell then exit("connection failed")
// START function(s) you want to use
//GetPasswd() // only for missions needed
GetBank() // get all bank passwords
//GetLibs() // for lib colleation (needs a lot of diskspace)
InstallRshell() // install rshell-backbone
// CLEANUP: TBD -> check if system.log is there, if not inform user to create an empty system.log
PrintWhite("cleanup /var/system.log ...\n")
localShell.scp(pathTemp + "/system.log", "/var/", remoteShell) // DOWNLOAD
exit("... connection to " + remoteHost + " closed")