0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Full Interactive Reverse-Shell

Posted at

記事を書こうと思ったきっかけ

よくCTFでシェルを取るときに、取ったはいいものの補完機能がなかったり
Ctrl-cでコネクションを終了してしまったりと、使い勝手が悪かったので
普段のシェルと同じ様に操作ができないか調べていました。
そうしたら、pythonとsttyを使った方法を見つけたので紹介しようと思います。

手順

順番 コマンド 実行する側
1 nc -lvnp [listening port] 自分
2 python3 -c 'import pty; pty.spawn("/bin/bash")' 標的
3 Ctrl-z 標的
4 stty raw -echo; fg 自分
5 reset 標的
6 export SHELL=[your shell] 標的
7 export TERM=[your terminal] 標的

補足

Ctrl-zで、取ったシェルを一時的に停止させておき、自分のシェルに戻る。
そしてstty raw -echo; fgを実行すると、また標的のシェルを再開する。
手順2は、手順1ですでに標的のシェルを取得した後の段階で実行するコマンドです。

何ができるようになるのか

上記の手順でコマンドを実行すれば、補完機能やCtrl-cを押しても
シェルが終了しなくなります。

まとめ

今回はReverse-Shellで役立つコマンドを紹介しました。
CTFをやるときなどに役立ててくれるとうれしいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?