independentt

(mSL) TCPWatch-DataForwarder

Aug 21st, 2019
13,514
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;TCP-Watch by independent
  2. ;Give credit to the author (me)
  3. ;Bugs fixed in this version!
  4. ;Thank you for using my script
  5. ;With this you can Man-In-The-Middle and see all data sent and received from both parts.
  6.  
  7. menu * {
  8.   TCPWatch-dataforwardv1.2:init
  9. }
  10.  
  11. alias init {
  12.   inc %aaa
  13.   if (%aaa == 1) {
  14.     hadd -m conf ip 127.0.0.1
  15.     hadd -m conf port 9051
  16.     hadd -m conf p2 9050
  17.   }
  18.   if (!$sock(fromnet).ip) socklisten -d 0.0.0.0 fromnet $hget(conf,port)
  19.   if (!$dialog(tcpwatch)) dialog -m tcpwatch tcpwatch
  20.   did -a tcpwatch 11 [Info] listening on port $hget(conf,port) redirect to $hget(conf,ip) $+ : $+ $hget(conf,p2) $crlf
  21.   did -a tcpwatch 11 [Info] Script has been started %aaa times
  22.  
  23. }
  24.  
  25. dialog tcpwatch {
  26.   title "TCPWatch-dataforward v1.2"
  27.   size -1 -1 351 300
  28.   option dbu
  29.   box "Config", 1, 4 4 66 65
  30.   edit "9051", 2, 42 16 22 10
  31.   text "Listen Port", 3, 7 17 32 8
  32.   edit "127.0.0.1", 4, 13 36 50 10
  33.   text "forward to ip", 5, 14 27 47 8
  34.   edit "9050", 6, 39 47 23 10
  35.   text "To Port", 7, 9 47 25 8
  36.   button "START", 8, 4 71 34 12
  37.   button "STOP", 9, 39 71 30 12
  38.   box "Debug", 10, 69 4 268 248
  39.   edit "", 11, 75 11 263 237, result multi autohs autovs hsbar vsbar limit 999999
  40.   button "CLEAR", 12, 107 269 37 12
  41.   button "SAVE", 13, 244 269 37 12
  42. }
  43.  
  44. on 1:dialog:tcpwatch:sclick:8:{
  45.   init
  46. }
  47. on 1:dialog:tcpwatch:edit:2:{
  48.   hadd -m conf port $did(tcpwatch,2)
  49.   did -a tcpwatch 11 [Info] changed listen port to $did(tcpwatch,2) $crlf
  50. }
  51. on 1:dialog:tcpwatch:edit:4:{
  52.   hadd -m conf ip $did(tcpwatch,4)
  53.   did -a tcpwatch 11 [Info] changed ip to $did(tcpwatch,4) $crlf
  54. }
  55. on 1:dialog:tcpwatch:edit:6:{
  56.   hadd -m conf p2 $did(tcpwatch,6)
  57.   did -a tcpwatch 11 [Info] changed forward port to $did(tcpwatch,6) $crlf
  58. }
  59. on 1:dialog:tcpwatch:sclick:9:{
  60.   sockclose fromnet*
  61.   sockclose redirect*
  62.   sockclose tcpwatch*
  63.   did -a tcpwatch 11 [Info] Closed port. $crlf
  64. }
  65. on 1:dialog:tcpwatch:sclick:13:{
  66.   %ticks = $ticks
  67.   savebuf -oi tcpwatch 11 data $+ %ticks $+ .txt
  68.   run data $+ %ticks $+ .txt
  69.  
  70. }
  71. on 1:dialog:tcpwatch:sclick:12:{
  72.   cleardiag 11
  73. }
  74. alias cleardiag {
  75.   did -r tcpwatch $1
  76. }
  77. on 1:SOCKREAD:fromnet*:{
  78.  
  79.   :loop
  80.   sockread &fromnet
  81.   if (!$sockbr) return
  82.   hadd -mb tcpwatch B $+ $sockname &fromnet
  83.   hadd -m tcpwatch $sockname $bvar(&fromnet,1,$bvar(&fromnet,0)).text $crlf
  84.   if (!$sock($replace($sockname,fromnet,redirect)).ip) sockopen $replace($sockname,fromnet,redirect) $hget(conf,ip) $hget(conf,p2)
  85.   if ($sock($replace($sockname,fromnet,redirect)).ip) .timer 1 2 sockwrite -anb $replace($sockname,fromnet,redirect) $len($hget(tcpwatch,B $+ $sockname))  $hget(tcpwatch,B $+ $sockname)
  86.   did -a tcpwatch 11 From Net Text: $hget(tcpwatch,$sockname)
  87.   goto loop
  88. }
  89.  
  90. on 1:SOCKREAD:redirect*:{
  91.  
  92.   :loop
  93.   sockread &redirect
  94.   if (!$sockbr) return
  95.   hadd -mb tcpwatch B $+ $sockname &redirect
  96.   hadd -m tcpwatch $sockname $bvar(&redirect,1,$bvar(&redirect,0)).text $crlf
  97.   if ($sock($replace($sockname,redirect,fromnet)).ip) .timer 1 2 sockwrite -anb $replace($sockname,redirect,fromnet) $len($hget(tcpwatch,B $+ $sockname)) $hget(tcpwatch,B $+ $sockname)
  98.   did -a tcpwatch 11 Redirect Text: $hget(tcpwatch,$sockname)
  99.   goto loop
  100. }
  101.  
  102. on 1:SOCKLISTEN:fromnet:{ %name = fromnet $+ $r(0,99999) | sockaccept %name |  if (!$sock($replace($sockname,fromnet,redirect)).ip) sockopen $replace(%name,fromnet,redirect) $hget(conf,ip) $hget(conf,p2) }
RAW Paste Data