Skip to content

Instantly share code, notes, and snippets.

@allquixotic
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allquixotic/c27b1fd2143966526f74 to your computer and use it in GitHub Desktop.
Save allquixotic/c27b1fd2143966526f74 to your computer and use it in GitHub Desktop.
cefthing

##New tool I wanna write!

###Assumptions:

  1. The end-user's system does not filter outbound traffic (so SSH is okay)
  2. User is running Windows Vista/7/8/8.1 (bitness irrelevant)
  3. Assume that a .NET Framework with the CLR 4 is installed
  4. The tool must not use an existing web browser or browser profile from the system
  5. No installation in Add/Remove Programs
  6. Distributed as a single .exe that launches immediately without prompting the user to unpack
  7. File size is not an issue, but since multiple files are probably needed, will need to unpack natives and EXEs to a temp dir
  8. UPX works on the end-user's system
  9. The end-user has little to no networking knowledge, and should not be able to trivially re-purpose the SSH proxy for activities other than the browser embedded in the program

###Specifications:

  1. Written in C#
  2. Targets .NET Framework 4.0 Client Profile
  3. Entire app and all dependencies built for 32-bit Windows
  4. Proxifier Piece: Intercepts all Winsock32 sockets created by any process with a GUI matching a list of process names, using, e.g. the Proxifier engine (non-free) or WideCap (freeware).
  5. SOCKS5 SSH Tunnel Piece: Wraps an existing SSH2 client implementation (PuTTY, OpenSSH, SSH.NET) and opens up localhost:port as a Dynamic port forward, which is actually a SOCKS5 proxy that's tunneled through SSH, that basically multiplexes an arbitrary number of TCP connections through a single SSH connection.
  6. Browser Piece: Displays a WPF or Windows Forms main window that embeds something like Chrome Embedded Framework -- something fast, with built-in Flash and not dependent on the user having a profile, and able to be displayed without allowing the user to navigate to an arbitrary URL (they might still be able to click around on the page they're navigated to and be able to "break out" to Google or something, which is OK if the site allows it, but they shouldn't have an editable Address Bar)
  7. Browser/Proxifier Integration: The Proxifier must force the Browser Piece and all of its plugins, such as Flash -- assuming that they use Winsock32 -- to be proxied through the SOCKS5 tunnel established by the SOCKS5 SSH Tunnel Piece.
  8. Coordinator Piece: A main process which displays no GUI but runs using the Win32 subsystem (so no terminal window) and spawns the Browser Piece, SOCKS5 piece, and Proxifier piece (assuming they're all separate processes; this may not be required). If any one of the processes dies, the Coordinator will kill the other child processes and then itself. If the Coordinator catches an unanticipated exception, it will attempt to do the same thing.

Example application flow:

  1. Coordinator process startup by double-clicking on Coordinator.exe.
  2. Find temporary directory; create temporary folder. Mark it for deletion upon clean exit of the Coordinator.
  3. Unpack Chromium Embedded Framework, the Proxifier, and the SSH client into the folder.
  4. Run the SSH client to set up the SOCKS5 proxy (make sure it starts non-interactively and logs in with the private key).
  5. Start the Proxifier using a pre-configured profile or the command line, telling it to proxify any process matching the name of the process(es) spawned by the Chromium Embedded Framework, or the Browser Piece (exe).
  6. Start the Browser Piece, a separate .NET executable with a GUI that displays the Chromium Embedded Framework as a control on a window (resizable, start maximized, etc.)
  7. If the user closes the Browser Piece, the process ends, which triggers the shutdown and cleanup processes of the Coordinator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment