网站流量的重要性,哔哩哔哩网页版稍后再看在哪里,邮箱网址查询,湛江网站Wargames与bash知识12
Bandit20
关卡提示#xff1a; 主目录中有一个setuid二进制文件#xff0c;它执行以下操作#xff1a;它在您指定为命令行参数的端口上连接到localhost。然后#xff0c;它从连接中读取一行文本#xff0c;并将其与前一级别的密码#xff08;band…Wargames与bash知识12
Bandit20
关卡提示 主目录中有一个setuid二进制文件它执行以下操作它在您指定为命令行参数的端口上连接到localhost。然后它从连接中读取一行文本并将其与前一级别的密码bandit20进行比较。如果密码正确它将传输下一级别bandit21的密码。 注意试着连接到您自己的网络守护程序看看它是否如您所想的那样工作
推荐命令 ssh, nc, cat, bash, screen, tmux, Unix ‘job control’ (bg, fg, jobs, , CTRL-Z, …)
有没有觉得的这个关卡有点眼熟某个关卡我们使用nc给一个端口好像是30000发送一个字符串然后服务器给回复一个密码。这个关卡是展现服务器端是如何实现的吧不过细究的还有有很大的区别那个关卡回复是自动的但在这个关卡我们需要手动运行一个程序才能实现。 Nc的命令前面已经谈过了就不再复述。 解决这个问题需要使用两个终端咱们继续使用windows的wls2子系统unbuntu来做演示。
使用ssh登录服务器 g
yjguyanjun:~$ ssh -l bandit20 -p 2220 bandit.labs.overthewire.org
The authenticity of host [bandit.labs.overthewire.org]:2220 ([51.20.13.48]:2220) cant be established.
ECDSA key fingerprint is SHA256:IJ7FrX0mKSSHTJ63ezxjqtnOE0Hg116Aqv5mN0HdE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added [bandit.labs.overthewire.org]:2220,[51.20.13.48]:2220 (ECDSA) to the list of known hosts._ _ _ _| |__ __ _ _ __ __| (_) |_| _ \ / _ | _ \ / _ | | __|| |_) | (_| | | | | (_| | | |_|_.__/ \__,_|_| |_|\__,_|_|\__|This is an OverTheWire game server.More information on http://www.overthewire.org/wargames………运行命令获得相关信息
bandit20bandit:~$ ./suconnect
Usage: ./suconnect portnumber
This program will connect to the given port on localhost using TCP. If it receives the correct password from the other side, the next password is transmitted back.使用左边的终端向端口11000发送字符串端口可以自行指定注意不要使用知名端口使用右边的终端运行./suconnect 11000命令获得所需密码 现在尝试发送一个错误是字符串看看会有什么报错 如果不喜欢使用的两个终端可以尝试将nc放入后台
b
andit20bandit:~$ nc -l 11000 VxCazJaVykI6W36BkBU0mJTCM8rR95XT
[1] 383771
bandit20bandit:~$ ./suconnect 11000
Read: VxCazJaVykI6W36BkBU0mJTCM8rR95XT
Password matches, sending next password
NvEJF7oVjkddltPSrdKEFOllh9V1IBcq
[1] Done nc -l 11000 VxCazJaVykI6W36BkBU0mJTCM8rR95XT
bandit20bandit:~$将linux命令放入后台的方法很简单直接在命令结尾添加一个 符号。为演示效果我使用while做了一个死循环。
gyjguyanjun:~$ while true ; do sleep 200; done
[1] 693返回的信息1 是任务后 693是进程号 可以使用jobs 查看后台运行的命令
gyjguyanjun:~$ jobs
[1] 运行中 while true; dosleep 200;
done 可以使用kill %1或者 kill 693 “杀死”后台进程
gyjguyanjun:~$ kill %1
gyjguyanjun:~$ jobs
[1] 已终止 while true; dosleep 200;
done使用fg 任务号将命令放回前台
gyjguyanjun:~$ fg
while true; dosleep 200;
done使用crtl-z 将命令暂停且放入后台
gyjguyanjun:~$ fg
while true; dosleep 200;
done
^Z
[1] 已停止 while true; dosleep 200;
done使用bg %1 恢复后台暂停的命令使其在后台运行
gyjguyanjun:~$ bg %1
[1] while true; dosleep 200;
done 这个技巧可以解决命令忘记放入后台的情况。
使用将命令放入后台如果关闭了shell终端后台的命令也会退出。为了解决这个问题可以使用 nohup命令
gyjguyanjun:~$ nohup sleep 2000
[2] 1261
gyjguyanjun:~$ nohup: 忽略输入并把输出追加到nohup.outgyjguyanjun:~$ nohup sleep 3000 aa.out
[3] 1264
gyjguyanjun:~$ nohup: 忽略输入重定向错误到标准输出端gyjguyanjun:~$ nohup sleep 3000 aa.out
[4] 1265gyjguyanjun:~$ jobs
[1] 运行中 while true; dosleep 200;
done
[2] 运行中 nohup sleep 2000
[3]- 运行中 nohup sleep 3000 aa.out
[4] 运行中 nohup sleep 3000 aa.out
gyjguyanjun:~$请注意使用nohup需要将后台的进程的输出处理一下shell退出以后后台程序原本输出到屏幕的输出就无处可去了。