linux-lcx

先po代码:

https://gist.github.com/wrfly/a55b11926e230e05a9a6

然后说用法:

➤ ./lcx 
Usage:./lcx -m method [host1] port1 [host2] port2 [-v] [-log filename]
 -v: version
 -m1: PORT1 HOST2 PORT2
 -m2: PORT1 PORT2
 -m3: HOST1 PORT1 HOST2 PORT2
 -log: log the data
For methods:
 -m1: listen on PORT1 and connect to HOST2:PORT2
 -m2: listen on PORT1 and PORT2
 -m3: connect to HOST1:PORT1 and HOST2:PORT2

粗略的解释下,希望对别人有帮助。

mode 1:

把本机的 port1 跟 host2 的 port2 连接起来(bind to connect)

➤ ./lcx -m1 8080 kfd.me 80
[+] Waiting for a response...
[-] Accept a client from 127.0.0.1:37044
[+] Making a connection to kfd.me:80...[+] Ok
[+] Waiting for a response...
[+] Connection closed.
[+] Waiting for a response...
^C➤ 

当你访问本机的8080端口时,实际上访问了 kfd.me 的80端口。

如果用Ncat的话,就是这样了:ncat --sh-exec "ncat kfd.me 80" -lk 8080 跟上面的作用相同。

mode 2:

把本机的 port1 和 port2 连接起来(bind to bind):

^C➤ ./lcx -m2 8080 8090
[+] Listening port 8080...
[+] Listen OK!
[+] Listening port 8090...
[+] Listen OK!
[+] Waiting for Client on port:8080...
^C➤ 

如果用Ncat的话,是这样的:ncat --sh-exec "ncat -lk 8090" -lk 8080

mode 3:

连接两个端口(connect to connect),而不是绑定它们,这个的作用就是内网转发,连接本机的3389端口或者22端口或者其他的端口,然后再连接一个有公网IP的机子,前提是这台机子事先已经在监听了。这样就会形成一个环路:

chicken:3389 <-> server:port1 <-> server:port2

然后 server 的 port2 就等价于 chicken 的3389了。

./lcx -m3 128.128.128.128 8989 127.0.0.1 22

上面的例子是转发内网的22端口到外面的服务器上,事先这台服务器运行了:。/lcx -m2 8989 2333

然后连接 ssh root@128.128.128.128 -p 2333 就可以连接那台内网的ssh了。

如果是用Ncat来做的话:

checken:ncat --sh-exec "ncat 127.0.0.1 80" msf.kfd.me 8989

server:ncat --sh-exec "ncat -lk 2333" -lk 8989

这样就可以达到与lcx同样的效果。

PS

如果是自己实验的话,开个80端口就好了。 然后,Ncat真牛逼。Lcx也牛逼。

comments powered by Disqus