();
32 | var windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
33 | var windowsAppsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsApps");
34 | var userProfileFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
35 | foreach (var process in Process.GetProcesses())
36 | {
37 | try
38 | {
39 | var path = process.MainModule?.FileName;
40 | if (path == null)
41 | continue;
42 |
43 | if (path.StartsWith(windowsFolder, StringComparison.OrdinalIgnoreCase))
44 | continue;
45 |
46 | if (path.StartsWith(windowsAppsFolder, StringComparison.OrdinalIgnoreCase))
47 | continue;
48 |
49 | if (mask)
50 | sortedSet.Add(path.Replace(userProfileFolder, "%USERPROFILE%"));
51 | else
52 | sortedSet.Add(path);
53 | }
54 | catch (Exception)
55 | {
56 | // ignored
57 | }
58 | }
59 |
60 | return sortedSet;
61 | }
62 | }
--------------------------------------------------------------------------------
/Netch/runtimeconfig.template.json:
--------------------------------------------------------------------------------
1 | {
2 | "rollForward": "Major"
3 | }
--------------------------------------------------------------------------------
/Other/.gitignore:
--------------------------------------------------------------------------------
1 | /release
2 |
--------------------------------------------------------------------------------
/Other/.must_build:
--------------------------------------------------------------------------------
1 | 3
--------------------------------------------------------------------------------
/Other/_Archive/build.ps1:
--------------------------------------------------------------------------------
1 | exit 0
--------------------------------------------------------------------------------
/Other/_Archive/chnip/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | try {
4 | Invoke-WebRequest `
5 | -Uri 'https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt' `
6 | -OutFile '..\..\release\bin\chnip.txt'
7 | }
8 | catch {
9 | exit 1
10 | }
11 |
12 | exit 0
--------------------------------------------------------------------------------
/Other/_Archive/chnsite/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | try {
4 | Invoke-WebRequest `
5 | -Uri 'https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf' `
6 | -OutFile 'chnsite.txt'
7 | }
8 | catch {
9 | exit 1
10 | }
11 |
12 | foreach ( $data in (Get-Content -Path 'chnsite.txt') ) {
13 | $data = $data.Replace('server=/', '')
14 | $data = $data.Replace('/114.114.114.114', '')
15 | $data = $data.Trim()
16 |
17 | if ( $data.Length -gt 0 ) {
18 | Add-Content -Path 'newsite.txt' -Value $data
19 | }
20 | }
21 |
22 | mv -Force 'newsite.txt' '..\..\release\bin\chnsite.txt'
23 | exit 0
--------------------------------------------------------------------------------
/Other/_Archive/cloak/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | git clone https://github.com/cbeuw/Cloak -b 'v2.5.5' src
4 | if ( -Not $? ) {
5 | exit $lastExitCode
6 | }
7 | Set-Location src
8 |
9 | $Env:CGO_ENABLED='0'
10 | $Env:GOROOT_FINAL='/usr'
11 |
12 | $Env:GOOS='windows'
13 | $Env:GOARCH='amd64'
14 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w' -o '..\..\release\ck-client.exe' '.\cmd\ck-client'
15 | exit $lastExitCode
--------------------------------------------------------------------------------
/Other/_Archive/dnsproxy/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | git clone https://github.com/AdguardTeam/dnsproxy -b 'v0.39.9' src
4 | if ( -Not $? ) {
5 | exit $lastExitCode
6 | }
7 | Set-Location src
8 |
9 | $Env:CGO_ENABLED='0'
10 | $Env:GOROOT_FINAL='/usr'
11 |
12 | $Env:GOOS='windows'
13 | $Env:GOARCH='amd64'
14 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w' -o '..\..\release\dnsproxy.exe'
15 | exit $lastExitCode
--------------------------------------------------------------------------------
/Other/_Archive/geoip/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | try {
4 | Invoke-WebRequest `
5 | -Uri 'https://github.com/v2fly/geoip/releases/latest/download/geoip.dat' `
6 | -OutFile '..\..\release\bin\geoip.dat'
7 | }
8 | catch {
9 | exit 1
10 | }
11 |
12 | exit 0
--------------------------------------------------------------------------------
/Other/_Archive/geosite/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | try {
4 | Invoke-WebRequest `
5 | -Uri 'https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat' `
6 | -OutFile '..\..\release\bin\geosite.dat'
7 | }
8 | catch {
9 | exit 1
10 | }
11 |
12 | exit 0
--------------------------------------------------------------------------------
/Other/_Archive/tun2socks/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | git clone https://github.com/xjasonlyu/tun2socks -b 'v2.3.2' src
4 | if ( -Not $? ) {
5 | exit $lastExitCode
6 | }
7 | Set-Location src
8 |
9 | $Env:CGO_ENABLED='0'
10 | $Env:GOROOT_FINAL='/usr'
11 |
12 | $Env:GOOS='windows'
13 | $Env:GOARCH='amd64'
14 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w' -o '..\..\release\tun2socks.exe'
15 | exit $lastExitCode
--------------------------------------------------------------------------------
/Other/_Archive/v2ray-core/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | git clone https://github.com/v2fly/v2ray-core -b 'v4.43.0' src
4 | if ( -Not $? ) {
5 | exit $lastExitCode
6 | }
7 | Set-Location src
8 |
9 | $Env:CGO_ENABLED='0'
10 | $Env:GOROOT_FINAL='/usr'
11 |
12 | $Env:GOOS='windows'
13 | $Env:GOARCH='amd64'
14 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w -buildid=' -o '..\..\release\v2ray.exe' '.\main'
15 | if ( -Not $? ) {
16 | exit $lastExitCode
17 | }
18 |
19 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w -buildid=' -tags confonly -o '..\..\release\v2ctl.exe' '.\infra\control\main'
20 | if ( -Not $? ) {
21 | exit $lastExitCode
22 | }
23 |
24 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w -buildid= -H windowsgui' -o '..\..\release\wv2ray.exe' '.\main'
25 | exit $lastExitCode
--------------------------------------------------------------------------------
/Other/_Archive/v2ray-plugin/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | git clone https://github.com/teddysun/v2ray-plugin -b 'v4.43.0' src
4 | if ( -Not $? ) {
5 | exit $lastExitCode
6 | }
7 | Set-Location src
8 |
9 | $Env:CGO_ENABLED='0'
10 | $Env:GOROOT_FINAL='/usr'
11 |
12 | $Env:GOOS='windows'
13 | $Env:GOARCH='amd64'
14 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w' -o '..\..\release\v2ray-plugin.exe'
15 | exit $lastExitCode
--------------------------------------------------------------------------------
/Other/aiodns/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | $Env:CGO_ENABLED='1'
4 | $Env:GOROOT_FINAL='/usr'
5 |
6 | $Env:GOOS='windows'
7 | $Env:GOARCH='amd64'
8 | go build -a -buildmode=c-shared -trimpath -asmflags '-s -w' -ldflags '-s -w' -o '..\release\aiodns.bin'
9 | exit $lastExitCode
10 |
--------------------------------------------------------------------------------
/Other/aiodns/deps.ps1:
--------------------------------------------------------------------------------
1 | Push-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | rm -Force go.*
4 | go mod init aiodns
5 | go mod tidy
6 |
7 | Pop-Location
8 | exit $lastExitCode
9 |
--------------------------------------------------------------------------------
/Other/aiodns/go.mod:
--------------------------------------------------------------------------------
1 | module aiodns
2 |
3 | go 1.17
4 |
5 | require github.com/miekg/dns v1.1.43
6 |
7 | require (
8 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
9 | golang.org/x/sys v0.0.0-20210303074136-134d130e1a04 // indirect
10 | )
11 |
--------------------------------------------------------------------------------
/Other/aiodns/go.sum:
--------------------------------------------------------------------------------
1 | github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg=
2 | github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
3 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
4 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
5 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
6 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8 | golang.org/x/sys v0.0.0-20210303074136-134d130e1a04 h1:cEhElsAv9LUt9ZUUocxzWe05oFLVd+AA2nstydTeI8g=
9 | golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
10 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
11 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
12 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
13 |
--------------------------------------------------------------------------------
/Other/build.ps1:
--------------------------------------------------------------------------------
1 | Push-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | .\clean.ps1
4 |
5 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
6 | Get-ChildItem -Path '.' -Directory | ForEach-Object {
7 | $name=$_.Name
8 |
9 | if ( Test-Path ".\$name\build.ps1" ) {
10 | Write-Host "Building $name"
11 |
12 | & ".\$name\build.ps1"
13 | if ( -Not $? ) {
14 | Write-Host "Build $name failed"
15 | exit $lastExitCode
16 | }
17 | }
18 |
19 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
20 | }
21 |
22 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
23 | Get-ChildItem -Path '.' -Directory | ForEach-Object {
24 | $name=$_.Name
25 |
26 | if ( Test-Path ".\$name\src" ) {
27 | rm -Recurse -Force ".\$name\src"
28 | }
29 |
30 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
31 | }
32 |
33 | Write-Host
34 |
35 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
36 | Get-ChildItem -Path '.\release' -File | ForEach-Object {
37 | $name=$_.Name
38 | $hash=(Get-FileHash ".\release\$name" -Algorithm SHA256).Hash.ToLower()
39 |
40 | Write-Host "$hash $name"
41 | }
42 |
43 | Pop-Location
44 | exit 0
45 |
--------------------------------------------------------------------------------
/Other/clean.ps1:
--------------------------------------------------------------------------------
1 | Push-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | if ( Test-Path 'build' ) {
4 | rm -Recurse -Force 'build'
5 | }
6 |
7 | if ( Test-Path 'release' ) {
8 | rm -Recurse -Force 'release'
9 | }
10 |
11 | Get-ChildItem -Path '.' -Directory | ForEach-Object {
12 | $name=$_.Name
13 |
14 | if ( Test-Path "$name\src" ) {
15 | rm -Recurse -Force "$name\src"
16 | }
17 | }
18 |
19 | Pop-Location
20 | exit 0
21 |
--------------------------------------------------------------------------------
/Other/deps.ps1:
--------------------------------------------------------------------------------
1 | Push-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | .\clean.ps1
4 |
5 | Get-ChildItem -Path '.' -Directory | ForEach-Object {
6 | Push-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
7 |
8 | $name=$_.Name
9 |
10 | if ( Test-Path ".\$name\deps.ps1" ) {
11 | & ".\$name\deps.ps1"
12 |
13 | if ( -Not $? ) {
14 | exit $lastExitCode
15 | }
16 | }
17 | }
18 |
19 | Pop-Location
20 | exit 0
21 |
--------------------------------------------------------------------------------
/Other/pcap2socks/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | try {
4 | Invoke-WebRequest `
5 | -Uri 'https://github.com/zhxie/pcap2socks/releases/download/v0.6.2/pcap2socks-v0.6.2-windows-amd64.zip' `
6 | -OutFile 'pcap2socks.zip'
7 | Expand-Archive -Force -Path pcap2socks.zip -DestinationPath pcap2socks
8 | }
9 | catch {
10 | exit 1
11 | }
12 |
13 | mv -Force 'pcap2socks\pcap2socks.exe' '..\release\pcap2socks.exe'
14 | exit 0
--------------------------------------------------------------------------------
/Other/wintun/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | try {
4 | Invoke-WebRequest `
5 | -Uri 'https://www.wintun.net/builds/wintun-0.13.zip' `
6 | -OutFile 'wintun.zip'
7 | }
8 | catch {
9 | exit 1
10 | }
11 |
12 | 7z x 'wintun.zip'
13 | if ( -Not $? ) { exit $lastExitCode }
14 |
15 | mv -Force 'wintun\bin\amd64\wintun.dll' '..\release\wintun.dll'
16 |
17 | rm -Recurse -Force 'wintun'
18 | rm -Recurse -Force 'wintun.zip'
19 | exit 0
--------------------------------------------------------------------------------
/Other/xray-core/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | git clone https://github.com/xtls/xray-core -b 'v1.8.7' src
4 | if ( -Not $? ) {
5 | exit $lastExitCode
6 | }
7 | Set-Location src
8 |
9 | $Env:CGO_ENABLED='0'
10 | $Env:GOROOT_FINAL='/usr'
11 |
12 | $Env:GOOS='windows'
13 | $Env:GOARCH='amd64'
14 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w -buildid=' -o '..\..\release\xray.exe' '.\main'
15 | exit $lastExitCode
16 |
--------------------------------------------------------------------------------
/Other/xray-plugin/build.ps1:
--------------------------------------------------------------------------------
1 | Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
2 |
3 | git clone https://github.com/teddysun/xray-plugin -b 'v1.8.7' src
4 | if ( -Not $? ) {
5 | exit $lastExitCode
6 | }
7 | Set-Location src
8 |
9 | $Env:CGO_ENABLED='0'
10 | $Env:GOROOT_FINAL='/usr'
11 |
12 | $Env:GOOS='windows'
13 | $Env:GOARCH='amd64'
14 | go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w' -o '..\..\release\xray-plugin.exe'
15 | exit $lastExitCode
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # `In preparation for 2.0, this repository will be cleared of all 1.0 related releases and code`
2 | 
3 |
4 |
5 |
6 | # Netch
7 | A simple proxy client
8 |
9 | [](https://t.me/netch_group)
10 | [](https://t.me/netch_channel)
11 | [](https://github.com/netchx/netch/releases)
12 | [](https://github.com/netchx/netch/releases)
13 |
14 |
15 | ## Features
16 | Some features may not be implemented in version 1
17 |
18 | ### Modes
19 | - `ProcessMode` - Use Netfilter driver to intercept process traffic
20 | - `ShareMode` - Share your network based on WinPcap / Npcap
21 | - `TunMode` - Use WinTUN driver to create virtual adapter
22 | - `WebMode` - Web proxy mode
23 |
24 | ### Protocols
25 | - [`Socks5`](https://www.wikiwand.com/en/SOCKS)
26 | - [`Shadowsocks`](https://shadowsocks.org)
27 | - [`ShadowsocksR`](https://github.com/shadowsocksrr/shadowsocksr-libev)
28 | - [`WireGuard`](https://www.wireguard.com)
29 | - [`Trojan`](https://trojan-gfw.github.io/trojan)
30 | - [`VMess`](https://www.v2fly.org)
31 | - [`VLESS`](https://xtls.github.io)
32 |
33 | ### Others
34 | - UDP NAT FullCone (Limited by your server)
35 | - .NET 6.0 x64
36 |
37 | ## Sponsor
38 |
39 |
40 | ## License
41 | Netch is licensed under the [GPLv3](https://raw.githubusercontent.com/netchx/netch/main/LICENSE) license
42 |
--------------------------------------------------------------------------------
/Redirector/.gitignore:
--------------------------------------------------------------------------------
1 | /bin
2 | /obj
3 | /*.vcxproj.user
4 |
--------------------------------------------------------------------------------
/Redirector/.must_build:
--------------------------------------------------------------------------------
1 | 1
--------------------------------------------------------------------------------
/Redirector/Based.cpp:
--------------------------------------------------------------------------------
1 | #include "Based.h"
2 |
3 | bool filterLoopback = false;
4 | bool filterIntranet = false;
5 | bool filterParent = false;
6 | bool filterICMP = true;
7 | bool filterTCP = true;
8 | bool filterUDP = true;
9 | bool filterDNS = true;
10 |
11 | DWORD icmping = 0;
12 |
13 | bool dnsOnly = false;
14 | bool dnsProx = true;
15 | string dnsHost = "1.1.1.1";
16 | USHORT dnsPort = 53;
17 |
18 | wstring tgtHost = L"127.0.0.1";
19 | wstring tgtPort = L"1080";
20 | string tgtUsername = "";
21 | string tgtPassword = "";
22 |
23 | vector bypassList;
24 | vector handleList;
25 |
--------------------------------------------------------------------------------
/Redirector/Based.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef BASED_H
3 | #define BASED_H
4 | #include
5 |
6 | #include