You've already forked greyhack
added bounce option in rootshell script
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
if params.len < 1 or params[0] == "-h" or params[0] == "--help" then
|
if params.len < 1 or params.len > 2 or params[0] == "-h" or params[0] == "--help" then
|
||||||
current_program = get_shell.host_computer.File(program_path)
|
current_program = get_shell.host_computer.File(program_path)
|
||||||
exit "Usage: " + current_program.name + " <remote ip>"
|
exit "Usage: " + current_program.name + " <gateway ip> [host ip]\n\nWithout host ip, scan the gateway and choose a port.\nWith host ip, try router bounce exploits on gateway:0 against host ip."
|
||||||
end if
|
end if
|
||||||
|
|
||||||
mx = include_lib("/lib/metaxploit.so")
|
mx = include_lib("/lib/metaxploit.so")
|
||||||
@@ -13,6 +13,11 @@ if not crypto then crypto = include_lib(current_path + "/crypto.so")
|
|||||||
local_shell = get_shell
|
local_shell = get_shell
|
||||||
local_cp = local_shell.host_computer
|
local_cp = local_shell.host_computer
|
||||||
ip = params[0]
|
ip = params[0]
|
||||||
|
bounce_host = ""
|
||||||
|
if params.len == 2 then bounce_host = params[1]
|
||||||
|
bounce_mode = bounce_host != ""
|
||||||
|
login_ip = ip
|
||||||
|
if bounce_mode then login_ip = bounce_host
|
||||||
KNOWN_PASS = "Root1234"
|
KNOWN_PASS = "Root1234"
|
||||||
|
|
||||||
rank_of = function(user)
|
rank_of = function(user)
|
||||||
@@ -22,6 +27,12 @@ rank_of = function(user)
|
|||||||
return 2
|
return 2
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
is_requested_host = function(comp)
|
||||||
|
if not bounce_mode then return 1
|
||||||
|
if not comp then return 0
|
||||||
|
return comp.local_ip == bounce_host
|
||||||
|
end function
|
||||||
|
|
||||||
extract_value = function(line)
|
extract_value = function(line)
|
||||||
start = line.indexOf("<b>")
|
start = line.indexOf("<b>")
|
||||||
finish = line.indexOf("</b>")
|
finish = line.indexOf("</b>")
|
||||||
@@ -94,7 +105,11 @@ redraw = function()
|
|||||||
end if
|
end if
|
||||||
clear_screen
|
clear_screen
|
||||||
last_clear[0] = time
|
last_clear[0] = time
|
||||||
|
if bounce_mode then
|
||||||
|
print ip + " 0 -> " + bounce_host
|
||||||
|
else
|
||||||
print ip + " " + chosen_port
|
print ip + " " + chosen_port
|
||||||
|
end if
|
||||||
for line in logs
|
for line in logs
|
||||||
print line
|
print line
|
||||||
end for
|
end for
|
||||||
@@ -115,6 +130,7 @@ end function
|
|||||||
|
|
||||||
take_shell = function(sh)
|
take_shell = function(sh)
|
||||||
if typeof(sh) != "shell" then return
|
if typeof(sh) != "shell" then return
|
||||||
|
if not is_requested_host(sh.host_computer) then return
|
||||||
user = object_user(sh.host_computer)
|
user = object_user(sh.host_computer)
|
||||||
if state.best_shell == null or rank_of(user) > rank_of(state.best_user) then
|
if state.best_shell == null or rank_of(user) > rank_of(state.best_user) then
|
||||||
state.best_shell = sh
|
state.best_shell = sh
|
||||||
@@ -126,6 +142,7 @@ end function
|
|||||||
|
|
||||||
take_computer = function(comp)
|
take_computer = function(comp)
|
||||||
if typeof(comp) != "computer" then return
|
if typeof(comp) != "computer" then return
|
||||||
|
if not is_requested_host(comp) then return
|
||||||
user = object_user(comp)
|
user = object_user(comp)
|
||||||
if state.best_computer == null or rank_of(user) > rank_of(object_user(state.best_computer)) then
|
if state.best_computer == null or rank_of(user) > rank_of(object_user(state.best_computer)) then
|
||||||
state.best_computer = comp
|
state.best_computer = comp
|
||||||
@@ -240,18 +257,22 @@ add_scan_row = function(port_num, state_name, libname, version, lan)
|
|||||||
push_ssh port_num, libname
|
push_ssh port_num, libname
|
||||||
end function
|
end function
|
||||||
|
|
||||||
print "scanning " + ip
|
if bounce_mode then
|
||||||
|
chosen_port = 0
|
||||||
|
note("bouncing through " + ip + " to " + bounce_host)
|
||||||
|
else
|
||||||
|
print "scanning " + ip
|
||||||
|
|
||||||
router_sess = mx.net_use(ip)
|
router_sess = mx.net_use(ip)
|
||||||
if router_sess then
|
if router_sess then
|
||||||
router_lib = router_sess.dump_lib
|
router_lib = router_sess.dump_lib
|
||||||
if router_lib then
|
if router_lib then
|
||||||
add_scan_row 0, "open", router_lib.lib_name, router_lib.version, ""
|
add_scan_row 0, "open", router_lib.lib_name, router_lib.version, ""
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
router = get_router(ip)
|
router = get_router(ip)
|
||||||
if router then
|
if router then
|
||||||
used = router.used_ports
|
used = router.used_ports
|
||||||
if used then
|
if used then
|
||||||
for p in used
|
for p in used
|
||||||
@@ -270,28 +291,31 @@ if router then
|
|||||||
add_scan_row p.port_number, st, lib.lib_name, lib.version, lan
|
add_scan_row p.port_number, st, lib.lib_name, lib.version, lan
|
||||||
end for
|
end for
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if scan_rows.len == 0 then exit("Unable to scan target")
|
if scan_rows.len == 0 then exit("Unable to scan target")
|
||||||
|
|
||||||
table = "PORT STATE LIBRARY VERSION LAN"
|
table = "PORT STATE LIBRARY VERSION LAN"
|
||||||
for row in scan_rows
|
for row in scan_rows
|
||||||
table = table + "\n" + row.port + " " + row.state + " " + row.lib + " " + row.version + " " + row.lan
|
table = table + "\n" + row.port + " " + row.state + " " + row.lib + " " + row.version + " " + row.lan
|
||||||
end for
|
end for
|
||||||
print format_columns(table)
|
print format_columns(table)
|
||||||
|
|
||||||
|
port_in = user_input("port: ")
|
||||||
|
chosen_port = port_in.to_int
|
||||||
|
if typeof(chosen_port) != "number" then exit("Invalid port")
|
||||||
|
end if
|
||||||
|
|
||||||
if ssh_ports.len == 0 then ssh_ports.push 22
|
if ssh_ports.len == 0 then ssh_ports.push 22
|
||||||
|
|
||||||
port_in = user_input("port: ")
|
|
||||||
chosen_port = port_in.to_int
|
|
||||||
if typeof(chosen_port) != "number" then exit("Invalid port")
|
|
||||||
|
|
||||||
try_login = function(user, password)
|
try_login = function(user, password)
|
||||||
if user == "" or password == "" then return null
|
if user == "" or password == "" then return null
|
||||||
|
if not bounce_mode then
|
||||||
sh = get_shell(user, password)
|
sh = get_shell(user, password)
|
||||||
if typeof(sh) == "shell" then return sh
|
if typeof(sh) == "shell" then return sh
|
||||||
|
end if
|
||||||
for ssh_port in ssh_ports
|
for ssh_port in ssh_ports
|
||||||
sh = local_shell.connect_service(ip, ssh_port, user, password)
|
sh = local_shell.connect_service(login_ip, ssh_port, user, password)
|
||||||
if typeof(sh) == "shell" then return sh
|
if typeof(sh) == "shell" then return sh
|
||||||
end for
|
end for
|
||||||
return null
|
return null
|
||||||
@@ -487,16 +511,22 @@ overflow_target = function(port_num, extras)
|
|||||||
end for
|
end for
|
||||||
end function
|
end function
|
||||||
|
|
||||||
extras = [""]
|
if bounce_mode then
|
||||||
if chosen_port == 0 then
|
extras = [bounce_host]
|
||||||
|
else
|
||||||
|
extras = [""]
|
||||||
|
if chosen_port == 0 then
|
||||||
for lan in lan_ips
|
for lan in lan_ips
|
||||||
if has_item(extras, lan) then continue
|
if has_item(extras, lan) then continue
|
||||||
extras.push lan
|
extras.push lan
|
||||||
end for
|
end for
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
if not bounce_mode then
|
||||||
|
if not has_item(extras, KNOWN_PASS) then extras.push KNOWN_PASS
|
||||||
|
mail = user_mail_address
|
||||||
|
if mail then extras.push mail
|
||||||
end if
|
end if
|
||||||
if not has_item(extras, KNOWN_PASS) then extras.push KNOWN_PASS
|
|
||||||
mail = user_mail_address
|
|
||||||
if mail then extras.push mail
|
|
||||||
|
|
||||||
note("exploiting port " + chosen_port)
|
note("exploiting port " + chosen_port)
|
||||||
overflow_target chosen_port, extras
|
overflow_target chosen_port, extras
|
||||||
|
|||||||
Reference in New Issue
Block a user