-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathwin-portfwd.ps1
More file actions
87 lines (70 loc) · 2.55 KB
/
win-portfwd.ps1
File metadata and controls
87 lines (70 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
$text = @"
_ _ _ ______ _ ______ _
| | | (_) | ___ \ | | | ___| | |
| | | |_ _ __ ______| |_/ /__ _ __| |_| |___ ____| |
| |/\| | | '_ \______| __/ _ \| '__| __| _\ \ /\ / / _` |
\ /\ / | | | | | | | (_) | | | |_| | \ V V / (_| |
\/ \/|_|_| |_| \_| \___/|_| \__\_| \_/\_/ \__,_|
Author : DeepZec
"@
write-host -fore green $text
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
do {
do {
write-host ""
write-host "A - Setup a port forwarding"
write-host "B - Show current fowarding list"
write-host "C - Remove all forwarding"
write-host ""
write-host "X - Exit"
write-host ""
write-host -nonewline "Type your choice and press Enter: "
$choice = read-host
write-host ""
$ok = $choice -match '^[abcdx]+$'
if ( -not $ok) { write-host "Invalid selection" }
} until ( $ok )
switch -Regex ( $choice ) {
"A"
{
do {
$Lhost = Read-Host -Prompt 'Enter local machine address'
$ok = $Lhost -match "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
if ( -not $ok) { write-host "Invalid host address" }
} until ( $ok )
do {
$Lport = Read-Host -Prompt 'Enter local port to listen'
$ok = [int]$Lport -le 65535
if ( -not $ok) { write-host "Invalid Port Number" }
} until ( $ok )
do {
$Rhost = Read-Host -Prompt 'Enter Remote server address'
$ok = $Lhost -match "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
if ( -not $ok) { write-host "Invalid host address" }
} until ( $ok )
do {
$Rport = Read-Host -Prompt 'Enter Remote port'
$ok = [int]$Lport -le 65535
if ( -not $ok) { write-host "Invalid Port Number" }
} until ( $ok )
if ( -not $ok) { write-host "Invalid user input" }
else {
netsh interface portproxy add v4tov4 listenaddress=$Lhost listenport=$Lport connectaddress=$Rhost connectport=$Rport
netsh interface portproxy show all
}
}
"B"
{
netsh interface portproxy show all
}
"C"
{
netsh interface portproxy reset
}
}
} until ( $choice -match "X" )