Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Sock5 Server Code
Browse files Browse the repository at this point in the history
 🐛
  • Loading branch information
Coldzer0 committed Nov 26, 2022
1 parent b73b244 commit 1af462c
Show file tree
Hide file tree
Showing 43 changed files with 52,498 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ dkms.conf
# Project Related
Socks5Agent/cmake-build-debug
Socks5Agent/cmake-build-release
Sock5Server/cmake-build-debug
Sock5Server/cmake-build-release
Build
cmake
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@

A tiny Reverse Sock5 Proxy


### Server

The Server GUI Built with ImGui :V

<img src="https://i.imgur.com/VMs92ep.png">

U can download a prebuilt from [Releases](https://github.com/Coldzer0/ReverseSock5Proxy/releases).
<br>

### Client/Agent

<b>Build it Yourself :P</b>

### TODO
- [ ] Finish the Server code
- Already done but need some refactoring :P
- [ ] Refactor the code to support multi OS
- [X] I don't know

### Resources

- https://www.rfc-editor.org/rfc/rfc1928
- [ImGui](https://github.com/ocornut/imgui)
- [nlohmann JSON](https://github.com/nlohmann/json)
- [mINI](https://github.com/pulzed/mINI)

<hr>

Expand Down
8 changes: 8 additions & 0 deletions Sock5Server/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Sock5Server/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Sock5Server/.idea/Sock5Server.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Sock5Server/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Sock5Server/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Sock5Server/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions Sock5Server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 3.22)

project ("SOCK5Server" CXX)

set(CMAKE_CXX_STANDARD 20)

# MSVC Static linking.
if(MSVC)
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()

# set the path to our cmake modules & generated cmake files from Conan.
set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# CONFIG option is important so that CMake doesnt search for modules into the default modules directory
find_package(imgui CONFIG)
find_package(glfw3 CONFIG)
find_package(glew CONFIG)

include_directories( "src" "src/UI" "src/UI/include" "src/bindings/imgui_backend" "src/bindings/stb" "src/bindings/mINI/src/mini")

# Locate all needed source & header files.
file(GLOB source_files CONFIGURE_DEPENDS
"src/UI/*.cpp"
"src/UI/*.h"
"src/UI/Font/*.h"
"src/UI/src/*.cpp"
"src/UI/include/*.h"
"src/UI/src/Sock5/*.cpp"
"src/UI/include/Sock5/*.h"
"src/bindings/imgui_backend/*.cpp"
"src/bindings/imgui_backend/*.h"
)
# Add source to this project's executable.
add_executable (SOCK5Server WIN32
"src/SOCK5Server.cpp"
"src/SOCK5Server.h"
${source_files}
"src/bindings/mINI/src/mini/ini.h"
"${CMAKE_CURRENT_SOURCE_DIR}/info.rc")

target_sources(SOCK5Server PRIVATE dpi-aware.manifest)

# Linker Options
target_compile_definitions(SOCK5Server PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLEW)
target_link_libraries(SOCK5Server imgui::imgui GLEW::glew_s glfw::glfw ws2_32)

# Static linking libgcc, libstdc++ and winpthread.
if(NOT MSVC)
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
# -fuse-ld=lld
target_link_options(SOCK5Server PRIVATE -static-libgcc -static-libstdc++ -static -lwinpthread -dynamic -pthread -O3)
elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug")
target_link_options(SOCK5Server PRIVATE -static-libgcc -static-libstdc++ -static -lwinpthread -dynamic -pthread -O0)
endif()
endif()

if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET SOCK5Server PROPERTY CXX_STANDARD 20)
endif()
45 changes: 45 additions & 0 deletions Sock5Server/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-debug",
"displayName": "x86 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
}
]
}
Binary file added Sock5Server/ICON.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions Sock5Server/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[requires]
imgui/cci.20220621+1.88.docking
glfw/3.3.7
glew/2.2.0

[generators]
cmake_find_package_multi

[options]
glew:shared=False

[imports]
./res/bindings, imgui_impl_glfw.cpp -> ../src/bindings/imgui_backend
./res/bindings, imgui_impl_opengl3.cpp -> ../src/bindings/imgui_backend
./res/bindings, imgui_impl_glfw.h -> ../src/bindings/imgui_backend
./res/bindings, imgui_impl_opengl3.h -> ../src/bindings/imgui_backend
./res/bindings, imgui_impl_opengl3_loader.h -> ../src/bindings/imgui_backend
9 changes: 9 additions & 0 deletions Sock5Server/dpi-aware.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</windowsSettings>
</application>
</assembly>
27 changes: 27 additions & 0 deletions Sock5Server/info.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
GLFW_ICON ICON DISCARDABLE ICON.ico
1 VERSIONINFO
FILEVERSION 0,0,1
PRODUCTVERSION 0,0,1
FILEOS 0x40004
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
BLOCK "040904b0"
{
VALUE "CompanyName", "Coldroot"
VALUE "FileDescription", "Coldroot Sock5 Server"
VALUE "FileVersion", "0.0.1"
VALUE "Full Version", "0.0.1"
VALUE "InternalName", "Coldroot"
VALUE "LegalCopyright", "Copyright \xA9 2022"
VALUE "OriginalFilename", "SOCK5Server.exe"
VALUE "ProductName", "Coldroot Sock5 Server"
VALUE "ProductVersion", "0.0.1"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409, 0x04B0
}
}
20 changes: 20 additions & 0 deletions Sock5Server/scripts/Generate_Build_GCC - Debug.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cd ..
if exist Build (
rmdir Build /Q /S
)
mkdir Build
if exist cmake (
rmdir cmake /Q /S
)
mkdir cmake

cd cmake
del *.txt *.cmake *.json *.lock
conan install .. -s build_type=Debug --build missing -s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=12 -s compiler.cppstd=20 -if ../cmake

cd ../Build
cmake -DCMAKE_BUILD_TYPE=Debug -G Ninja -S .. -B .
cmake --build . --target SOCK5Server -j 12

cd ../scripts
pause
20 changes: 20 additions & 0 deletions Sock5Server/scripts/Generate_Build_GCC - Release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cd ..
if exist Build (
rmdir Build /Q /S
)
mkdir Build
if exist cmake (
rmdir cmake /Q /S
)
mkdir cmake

cd cmake
del *.txt *.cmake *.json *.lock
conan install .. -s build_type=Release --build missing -s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=12 -s compiler.cppstd=20 -if ../cmake

cd ../Build
cmake -DCMAKE_BUILD_TYPE=Release -G Ninja -S .. -B .
cmake --build . --target SOCK5Server -j 12 --config Release

cd ../scripts
pause
24 changes: 24 additions & 0 deletions Sock5Server/scripts/Generate_Build_MSVC - Debug.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
cd ..
if exist Build (
rmdir Build /Q /S
)
mkdir Build
if exist cmake (
rmdir cmake /Q /S
)
mkdir cmake

cd cmake

conan install .. -s build_type=Debug --build missing -s compiler.runtime=MTd -s compiler="Visual Studio" -s compiler.cppstd=20 -if ../cmake
if %ERRORLEVEL% GEQ 1 EXIT /B 1

cd ../Build
cmake -DCMAKE_BUILD_TYPE=Debug -S .. -B .
if %ERRORLEVEL% GEQ 1 EXIT /B 1
cmake --build . --target SOCK5Server -j 12 --config Debug
if %ERRORLEVEL% GEQ 1 EXIT /B 1
cd ../scripts

pause
23 changes: 23 additions & 0 deletions Sock5Server/scripts/Generate_Build_MSVC - Release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off
cd ..
if exist Build (
rmdir Build /Q /S
)
mkdir Build
if exist cmake (
rmdir cmake /Q /S
)
mkdir cmake

cd cmake
conan install .. -s build_type=Release --build missing -s compiler.runtime=MT -s compiler="Visual Studio" -s compiler.cppstd=20 -if ../cmake
if %ERRORLEVEL% GEQ 1 EXIT /B 1

cd ../Build
cmake -DCMAKE_BUILD_TYPE=Release -S .. -B .
if %ERRORLEVEL% GEQ 1 EXIT /B 1
cmake --build . --target SOCK5Server -j 12 --config Release
if %ERRORLEVEL% GEQ 1 EXIT /B 1
cd ../scripts

pause
21 changes: 21 additions & 0 deletions Sock5Server/src/SOCK5Server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Reverse TCP Sock5 Proxy
* Copyright(c) 2022 - Coldzer0 <Coldzer0 [at] protonmail.ch> @Coldzer0x0
*/

#ifdef _DIST
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif

#include "UI/GUI_backend.h"
#include <Windows.h>

extern "C" {
[[maybe_unused]] __declspec(dllexport) uint32_t NvOptimusEnablement = 1;
[[maybe_unused]] __declspec(dllexport) uint32_t AmdPowerXpressRequestHighPerformance = 1;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
InitServerGui();
return 0;
}
3 changes: 3 additions & 0 deletions Sock5Server/src/SOCK5Server.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once
#include <Windows.h>

Loading

0 comments on commit 1af462c

Please sign in to comment.