vxProxy Tool - Automatically set IE Proxy

BinaryX Sep 15, 2013

  1. BinaryX

    BinaryX Lifetime Gold XPG Developer Lifetime Gold
    0/47

    Joined:
    May 21, 2011
    Messages:
    971
    Likes Received:
    258
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Europe
    Console:
    Xbox
    Hi XPG,

    This is my first application in unmanaged C++.
    What this does is automatically modify the ProxyEnable and ProxyServer keys in the registry.

    Usage: vxproxy.exe -p <enable/disable> -u <url:port>

    Download

    Source
    vxProxy.h
    #pragma once

    #include <stdio.h>
    #include <tchar.h>
    #include <windows.h>
    #include <STDLIB.H>

    #include <iostream>
    #include <sstream>
    #include <string>
    #include <algorithm>
    #include <iterator>
    #include <vector>

    void set_proxy(bool, std::string);
    template<typename T>
    std::vector<T> split(const T & str, const T & delimiters);

    vxProxy.cpp
    #include "vxProxy.h"

    using namespace std;

    int main(int argc, char* argv[])
    {
    cout << "IE Proxy Tool (c) VizionX ( http://www.vizionx.eu/ )" << endl;
    cout << "Note: this will only work when run as administrator." << endl;
    cout << endl;
    if (argc < 4) {
    std::cout << "Usage is vxproxy.exe -p <enable/disable> -u <url:port>\n";
    std::cin.get();
    exit(0);
    } else {
    bool bEnable = false;
    string url;
    for (int i = 1; i < argc; i++) {
    if(strcmp(argv, "-p") == 0) {
    if(strcmp(argv[i + 1], "enable") == 0)
    bEnable = true;
    }
    else if(strcmp(argv, "-u") == 0)
    url = argv[i + 1];
    }
    set_proxy(bEnable, url);
    std::cin.get();
    exit(0);
    }
    return 0;
    }

    void set_proxy(bool bEnable, string address)
    {
    if(bEnable) {
    vector<string> x = split<string>(address, ":");
    const char *addr = x[0].c_str();
    const char *port = x[1].c_str();
    stringstream ss;
    ss << "reg add \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\" /v ProxyServer /t REG_SZ /d " << addr << ":" << port << " /f";

    const char *cEnable = "reg add \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\" /v ProxyEnable /t REG_DWORD /d 1 /f >nul 2>&1";
    system(cEnable);

    string sSetUrl = ss.str();
    const char *cSetUrl = sSetUrl.c_str();
    system(cSetUrl);

    cout << "IE Proxy [ Enabled ]" << endl;
    } else {
    const char *cDisable = "reg add \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\" /v ProxyEnable /t REG_DWORD /d 0 /f >nul 2>&1";
    system(cDisable);

    cout << "IE Proxy [ Disabled ]";
    }
    }
    template<typename T>
    vector<T> split(const T & str, const T & delimiters) {
    vector<T> v;
    T::size_type start = 0;
    auto pos = str.find_first_of(delimiters, start);
    while(pos != T::npos) {
    if(pos != start)
    v.emplace_back(str, start, pos - start);
    start = pos + 1;
    pos = str.find_first_of(delimiters, start);
    }
    if(start < str.length())
    v.emplace_back(str, start, str.length() - start);
    return v;
    }


     
  2. Bu

    Bullet Guest

    Nice work NullBy7e
     
  3. BinaryX

    BinaryX Lifetime Gold XPG Developer Lifetime Gold
    0/47

    Joined:
    May 21, 2011
    Messages:
    971
    Likes Received:
    258
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Europe
    Console:
    Xbox
    I need some ideas for next program, suggest anything that's fun to make and not too time consuming.
     

Share This Page

Close