TCPWatch-DataForwarder

By independent911 on Aug 21, 2019

New version v1.2 out Sep 14th 2019

;TCP-Watch by independent
;Give credit to the author (me)
;Bugs fixed in this version!
;Thank you for using my script
;With this you can Man-In-The-Middle and see all data sent and received from both parts.

menu * {
  TCPWatch-dataforwardv1.2:init
}

alias init {
  inc %aaa
  if (%aaa == 1) {
    hadd -m conf ip 127.0.0.1
    hadd -m conf port 9051
    hadd -m conf p2 9050
  }
  if (!$sock(fromnet).ip) socklisten -d 0.0.0.0 fromnet $hget(conf,port)
  if (!$dialog(tcpwatch)) dialog -m tcpwatch tcpwatch
  did -a tcpwatch 11 [Info] listening on port $hget(conf,port) redirect to $hget(conf,ip) $+ : $+ $hget(conf,p2) $crlf
  did -a tcpwatch 11 [Info] Script has been started %aaa times

}

dialog tcpwatch {
  title "TCPWatch-dataforward v1.2"
  size -1 -1 351 300
  option dbu
  box "Config", 1, 4 4 66 65
  edit "9051", 2, 42 16 22 10
  text "Listen Port", 3, 7 17 32 8
  edit "127.0.0.1", 4, 13 36 50 10
  text "forward to ip", 5, 14 27 47 8
  edit "9050", 6, 39 47 23 10
  text "To Port", 7, 9 47 25 8
  button "START", 8, 4 71 34 12
  button "STOP", 9, 39 71 30 12
  box "Debug", 10, 69 4 268 248
  edit "", 11, 75 11 263 237, result multi autohs autovs hsbar vsbar limit 999999
  button "CLEAR", 12, 107 269 37 12
  button "SAVE", 13, 244 269 37 12
}

on 1:dialog:tcpwatch:sclick:8:{
  init
}
on 1:dialog:tcpwatch:edit:2:{
  hadd -m conf port $did(tcpwatch,2)
  did -a tcpwatch 11 [Info] changed listen port to $did(tcpwatch,2) $crlf
}
on 1:dialog:tcpwatch:edit:4:{
  hadd -m conf ip $did(tcpwatch,4)
  did -a tcpwatch 11 [Info] changed ip to $did(tcpwatch,4) $crlf
}
on 1:dialog:tcpwatch:edit:6:{
  hadd -m conf p2 $did(tcpwatch,6)
  did -a tcpwatch 11 [Info] changed forward port to $did(tcpwatch,6) $crlf
}
on 1:dialog:tcpwatch:sclick:9:{
  sockclose fromnet*
  sockclose redirect*
  sockclose tcpwatch*
  did -a tcpwatch 11 [Info] Closed port. $crlf
}
on 1:dialog:tcpwatch:sclick:13:{
  %ticks = $ticks
  savebuf -oi tcpwatch 11 data $+ %ticks $+ .txt
  run data $+ %ticks $+ .txt

}
on 1:dialog:tcpwatch:sclick:12:{
  cleardiag 11
}
alias cleardiag {
  did -r tcpwatch $1
}
on 1:SOCKREAD:fromnet*:{

  :loop
  sockread &fromnet
  if (!$sockbr) return
  hadd -mb tcpwatch B $+ $sockname &fromnet
  hadd -m tcpwatch $sockname $bvar(&fromnet,1,$bvar(&fromnet,0)).text $crlf
  if (!$sock($replace($sockname,fromnet,redirect)).ip) sockopen $replace($sockname,fromnet,redirect) $hget(conf,ip) $hget(conf,p2)
  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)
  did -a tcpwatch 11 From Net Text: $hget(tcpwatch,$sockname)
  goto loop
}

on 1:SOCKREAD:redirect*:{

  :loop
  sockread &redirect
  if (!$sockbr) return
  hadd -mb tcpwatch B $+ $sockname &redirect
  hadd -m tcpwatch $sockname $bvar(&redirect,1,$bvar(&redirect,0)).text $crlf
  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)
  did -a tcpwatch 11 Redirect Text: $hget(tcpwatch,$sockname)
  goto loop
}

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) }

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.