Skip to content

Commit f796c58

Browse files
committed
update
1 parent f43eb3d commit f796c58

File tree

1 file changed

+118
-4
lines changed
  • docs/Independent-Environment/OverTheWire/FormulaOne

1 file changed

+118
-4
lines changed

docs/Independent-Environment/OverTheWire/FormulaOne/index.md

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,9 +722,9 @@ formulaone2@bandit:/tmp/randark/formulaone-3$ file /formulaone/formulaone3*
722722

723723
可以看到,关闭了 `Canary` 保护,可以考虑 `ret2shellcode`
724724

725-
需要注意的是,环境只是提供了`suid`权限,那么即使getshell之后,也无法直接切换到`formulaone3`用户。那么目标就很明确了,直接打文件读取即可
725+
需要注意的是,环境只是提供了 `suid` 权限,那么即使 getshell 之后,也无法直接切换到 `formulaone3` 用户。那么目标就很明确了,直接打文件读取即可
726726

727-
首先,先生成shellcode
727+
首先,先生成 shellcode
728728

729729
```python
730730
from pwn import *
@@ -734,9 +734,9 @@ payload = asm(shellcraft.cat('/etc/formulaone_pass/formulaone3'))
734734
print(list(payload))
735735
```
736736

737-
得到shellcode之后,从共享内存部分下手,写入shellcode进`msg->ptr`的同时,满足条件竞争
737+
得到 shellcode 之后,从共享内存部分下手,写入 shellcode 进 `msg->ptr` 的同时,满足条件竞争
738738

739-
`echo->sz`先保证小于`buf`的长度,通过长度检查,然后改`echo->sz`为能完整读取`shellcode`的值,进而可以加载shellcode
739+
`echo->sz` 先保证小于 `buf` 的长度,通过长度检查,然后改 `echo->sz` 为能完整读取 `shellcode` 的值,进而可以加载 shellcode
740740

741741
```c
742742
/*'09 codegate chal
@@ -817,5 +817,119 @@ ssh [email protected] -p 2232
817817
查看挑战的代码
818818

819819
```c
820+
/*
821+
* -( nemo1.c )-
822+
* by nemo 2005
823+
*
824+
* v0.2
825+
*
826+
* Bit of fun, for #social.
827+
*
828+
* Thanks to hawkes for working on this with me
829+
* to make it exploitable.
830+
*
831+
* http://www.pulltheplug.org (now overthewire.org)
832+
*/
820833

834+
#include <stdio.h>
835+
#include <stdlib.h>
836+
#include <signal.h>
837+
#include <string.h>
838+
839+
#define NBUFSIZ 1024
840+
841+
char *buf, *brrr;
842+
void (*mfptrr)();
843+
char buf2[NBUFSIZ];
844+
845+
void func1(char *arg)
846+
{
847+
char envar[NBUFSIZ + 1];
848+
strncpy(envar, arg, NBUFSIZ);
849+
envar[NBUFSIZ] = 0;
850+
printf("[*] Environment variable: %s\n", envar);
851+
return;
852+
}
853+
854+
void int_handler()
855+
{
856+
if (strlen(buf) >= NBUFSIZ - 1)
857+
{
858+
exit(1);
859+
}
860+
861+
memcpy(buf2, buf, strlen(buf) - 1);
862+
printf("[+] Local buffer: %s.\n", buf2);
863+
864+
mfptrr(0);
865+
}
866+
867+
void cont_handler()
868+
{
869+
printf("[+] :D\n");
870+
871+
mfptrr(0);
872+
}
873+
874+
void check_main(char **av)
875+
{
876+
int a, b, c;
877+
char *home;
878+
long key;
879+
880+
if (home = getenv("HOME"))
881+
{
882+
if (home[1])
883+
{
884+
a = rand();
885+
b = (int)home[0];
886+
c = (int)home[1];
887+
key = a + b + c;
888+
}
889+
}
890+
if (key == 0xdeadbeef)
891+
{
892+
signal(SIGINT, int_handler);
893+
signal(SIGCONT, cont_handler);
894+
895+
if (getenv("TIMER"))
896+
sleep(1); // weak :P
897+
898+
buf = malloc(NBUFSIZ + 1);
899+
strncpy(buf, av[1], NBUFSIZ);
900+
buf[NBUFSIZ] = 0;
901+
}
902+
903+
return;
904+
}
905+
906+
int main(int ac, char **av, char **env)
907+
{
908+
char **tmp = env, *loc_brrr;
909+
mfptrr = exit;
910+
911+
srand(0xcafebabe);
912+
913+
if ((long)&buf2 > (long)&mfptrr)
914+
{
915+
printf("[!] Sorry, it's unlikely you can exploit this with your version of gcc.\n");
916+
printf("[!] feel free to remove this check, and let me know if you get it working.\n");
917+
exit(1);
918+
}
919+
920+
if (getenv("BUFFER"))
921+
buf = strdup(getenv("BUFFER"));
922+
923+
if (getenv("TERM"))
924+
brrr = strdup(getenv("TERM"));
925+
926+
while (*(++tmp))
927+
func1(*tmp);
928+
929+
check_main(av);
930+
931+
return 1;
932+
}
821933
```
934+
935+
TODO 接下来完全没有可利用的可能性

0 commit comments

Comments
 (0)