EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group

 

Affiliates



The Urinal

hackhound.org

suck-o.com

hack.org.za

flyninja.net

 

Enigma Group's Code Bank


OOP SOCKS5 Proxy using select()

By: BinaryShinigami  -  Date Submitted: 2009-04-13 00:04:00

  1. If you replace the winsock initialization code and cleanup code and the WSAGetLastError() function with the linux equivalents the code will run fine under linux, Will post up when I get around to it.
  2.  
  3. [DIR = ./]
  4. [FILE = ./main.cpp]
  5. #include <iostream>
  6. #include "socksHandler/sHandler.h"
  7. #include <winsock2.h>
  8. #include <vector>
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. cout << "Binary SOCKS5 Server V 0.1b" <<endl;
  15. cout <<"Currently only supports TCP connections with the Connect command." <<endl;
  16.  
  17. WSAData wsaData;
  18. struct sockaddr_in server;
  19. int sockErr;
  20. int accSocket;
  21. unsigned short listenPort = 6666;
  22. FD_SET constSet;
  23. FD_SET retSet;
  24. timeval waitTime;
  25. int socksRdy;
  26. bool running = true;
  27. vector<sHandler*> users;
  28. int tmpSocket;
  29.  
  30. sockErr = WSAStartup(MAKEWORD(2,2),&wsaData);
  31. if (sockErr == SOCKET_ERROR)
  32. {
  33. cerr <<"ERROR : " <<WSAGetLastError();
  34. return -1;
  35. }
  36.  
  37.  
  38. accSocket = socket(AF_INET,SOCK_STREAM,0);
  39. if (accSocket == SOCKET_ERROR)
  40. {
  41. cerr <<"ERROR: " <<WSAGetLastError();
  42. return -2;
  43. }
  44.  
  45. server.sin_family = AF_INET;
  46. server.sin_port = htons(listenPort);
  47. server.sin_addr.s_addr = INADDR_ANY;
  48.  
  49. sockErr = bind(accSocket,(sockaddr*)&server,sizeof(server));
  50. if (sockErr == SOCKET_ERROR)
  51. {
  52. cerr <<"Error: Unable to bind Socket: " <<WSAGetLastError() <<endl;
  53. return -3;
  54. }
  55.  
  56. sockErr = listen(accSocket,10);
  57. if (sockErr == SOCKET_ERROR)
  58. {
  59. cerr <<"Unable to listen on socket: " <<WSAGetLastError() <<endl;
  60. return -4;
  61. }
  62.  
  63. waitTime.tv_sec = 0;
  64. waitTime.tv_usec = 0;
  65.  
  66. FD_ZERO(&constSet);
  67. FD_ZERO(&retSet);
  68.  
  69. FD_SET(accSocket,&constSet);
  70. retSet = constSet;
  71.  
  72.  
  73. while(running)
  74. {
  75. retSet = constSet;
  76.  
  77. socksRdy = select(retSet.fd_count,&retSet,NULL,NULL,&waitTime);
  78. if (socksRdy == SOCKET_ERROR)
  79. {
  80. running = false;
  81. int er = WSAGetLastError();
  82. cerr <<"Unable to select() sockets: " <<er <<endl;
  83. if (er == WSAEINTR)
  84. {
  85. cout <<"WSAEINTR" <<endl;
  86. }
  87. cerr <<"socksRdy = " <<socksRdy <<endl;
  88. return -5;
  89. }
  90. if (retSet.fd_count > 0)
  91. {
  92. cout <<"Accepted User" <<endl;
  93. tmpSocket = accept(accSocket,0,0);
  94. sHandler *usr = new sHandler(tmpSocket);
  95. users.push_back(usr);
  96. }
  97. for(int i = 0; i< users.size();i++)
  98. {
  99. if (users[i]->active)
  100. users[i]->m_HandleTransfers();
  101. else
  102. {
  103. sHandler *tmpHandler;
  104. vector<sHandler*>::iterator it;
  105. for (it = users.begin(); it < users.end(); it++)
  106. {
  107. if ((*it)->unique_id == users[i]->unique_id)
  108. {
  109. tmpHandler = users[i];
  110. users.erase(it);
  111. break;
  112. }
  113. }
  114. delete tmpHandler;
  115. }
  116. }
  117. }
  118.  
  119.  
  120. closesocket(accSocket);
  121. WSACleanup();
  122.  
  123. return 0;
  124. }
  125. [DIR = ./socksHandler/]
  126. [FILE = ./socksHandler/sAuthReply.cpp]
  127. #include "sAuthReply.h"
  128.  
  129. sAuthReply::sAuthReply()
  130. {
  131. this->m_cMethod = '\0';
  132. this->m_cVer = S_VER;
  133. }
  134.  
  135. sAuthReply::~sAuthReply()
  136. {
  137.  
  138. }
  139. [FILE = ./socksHandler/sAuthReply.h]
  140. #ifndef SAUTHREPLY_H_INCLUDED
  141. #define SAUTHREPLY_H_INCLUDED
  142.  
  143. #include "sProto.h"
  144.  
  145. class sAuthReply {
  146.  
  147. public:
  148. sAuthReply();
  149. ~sAuthReply();
  150.  
  151. char m_cVer;
  152. char m_cMethod;
  153.  
  154. };
  155.  
  156.  
  157. #endif // SAUTHREPLY_H_INCLUDED
  158. [FILE = ./socksHandler/sAuthRequest.cpp]
  159. #include "sAuthRequest.h"
  160.  
  161. sAuthRequest::sAuthRequest()
  162. {
  163. this->m_cNumMethods = '\0';
  164. this->m_cVer = S_VER;
  165. memset(this->m_szMethods,0,sizeof(this->m_szMethods));
  166. }
  167.  
  168. sAuthRequest::~sAuthRequest()
  169. {
  170.  
  171. }
  172. [FILE = ./socksHandler/sAuthRequest.h]
  173. #ifndef SAUTHREQUEST_H_INCLUDED
  174. #define SAUTHREQUEST_H_INCLUDED
  175.  
  176. #include "sProto.h"
  177. #include <cstring>
  178.  
  179. class sAuthRequest
  180. {
  181. public:
  182. sAuthRequest();
  183. ~sAuthRequest();
  184.  
  185. char m_cVer;
  186. char m_cNumMethods;
  187. char m_szMethods[256];
  188. };
  189.  
  190. #endif // SAUTHREQUEST_H_INCLUDED
  191. [FILE = ./socksHandler/sHandler.cpp]
  192. #include "sHandler.h"
  193.  
  194. unsigned int sHandler::g_id = 0;
  195.  
  196. sHandler::sHandler(int clientSocket)
  197. {
  198. this->isAuthed = false;
  199. this->isConnected = false;
  200. this->usrSocket = clientSocket;
  201. this->dstSocket = socket(AF_INET,SOCK_STREAM,0);
  202. memset(tmpBuffer,0,256);
  203. FD_ZERO(&this->allSocks);
  204. FD_ZERO(&this->rdySocks);
  205. authRequest = new sAuthRequest();
  206. authReply = new sAuthReply();
  207. request = new sRequest();
  208. reply = new sReply();
  209. this->active = true;
  210. unique_id = sHandler::g_id++;
  211. tmpSize = '\0';
  212. rdyCount = 0;
  213. waitTime.tv_sec = 0;
  214. waitTime.tv_usec = 0;
  215. memset(&locallyBoundInfo,0,sizeof(sockaddr));
  216. }
  217.  
  218. sHandler::~sHandler()
  219. {
  220.  
  221. if (this->dstSocket != 0)
  222. {
  223. closesocket(this->dstSocket);
  224. }
  225.  
  226. closesocket(this->usrSocket);
  227. delete authRequest;
  228. delete authReply;
  229. delete request;
  230. delete reply;
  231. cout <<"Deleted" <<endl;
  232.  
  233. }
  234.  
  235. void sHandler::m_HandleTransfers()
  236. {
  237. //This function is called in every one of the classes and allows us to transfer the data back and forth
  238. ;
  239. if (!this->isAuthed)
  240. {
  241. if (!this->m_Validate())
  242. {
  243. this->active = false;
  244. }
  245. }
  246. else
  247. {
  248. //Connected and Authorized now its time to connect to a server etc..
  249.  
  250. if (!this->m_HandleTunnel())
  251. {
  252. this->active = false;
  253. }
  254. }
  255.  
  256.  
  257.  
  258. }
  259.  
  260. //This function handles the authentication process, Currently this server does not support authentication
  261.  
  262. bool sHandler::m_Validate()
  263. {
  264. if (this->isAuthed)
  265. {
  266. return true;
  267. }
  268. else
  269. {
  270.  
  271. //Handle the initial authentication of the client here
  272.  
  273. m_BytesRead = recv(usrSocket,(char*)&authRequest->m_cVer,1,0);
  274.  
  275. if ((this->m_BytesRead < 1) || (this->m_BytesRead == SOCKET_ERROR))
  276. {
  277. this->m_SockErr = WSAGetLastError();
  278. cerr <<" Reading Version Error: " << this->m_SockErr <<endl;
  279. cout <<"Recived: " <<authRequest->m_cVer <<endl;
  280. cout <<"Bytes Read: " <<m_BytesRead;
  281. return false;
  282. }
  283. else
  284. {
  285. m_BytesRead = recv(this->usrSocket,(char*)&authRequest->m_cNumMethods,1,0);
  286. if ((this->m_BytesRead < 1) || ( this->m_BytesRead > 1))
  287. {
  288. this->m_SockErr = WSAGetLastError();
  289. cerr <<"Reading numMethods Error: " <<this->m_SockErr <<endl;
  290. return false;
  291. }
  292.  
  293. m_BytesRead = recv(this->usrSocket,(char*)authRequest->m_szMethods,(int)authRequest->m_cNumMethods,0);
  294. cout <<"Recieved " <<m_BytesRead <<"Bytes, expecting " <<(int)authRequest->m_cNumMethods <<endl;
  295. cout <<authRequest->m_szMethods <<endl;
  296.  
  297.  
  298. if (this->authRequest->m_cVer != S_VER)
  299. {
  300. this->authReply->m_cMethod = S_NO_OK_METHOD;
  301. }
  302. else
  303. {
  304. this->authReply->m_cMethod = S_NO_AUTH_REQ;
  305. }
  306.  
  307. this->m_BytesRead = send(this->usrSocket,(char*)&this->authReply->m_cVer,1,0);
  308. if (this->m_BytesRead < 1)
  309. {
  310. this->m_SockErr = WSAGetLastError();
  311. cerr <<"Sending Version Error: " <<this->m_SockErr <<endl;
  312. }
  313. this->m_BytesRead = send(this->usrSocket,(char*)&this->authReply->m_cMethod,1,0);
  314. if (this->m_BytesRead < 1)
  315. {
  316. this->m_SockErr = WSAGetLastError();
  317. cerr <<"Sending Method Error: " <<this->m_SockErr <<endl;
  318. }
  319.  
  320. cout <<"Connected Successfully to client, waiting CONNECT." <<endl;
  321. //FINISHED AUTH
  322.  
  323.  
  324. this->isAuthed = true;
  325. return true;
  326. }
  327.  
  328. }
  329. }
  330.  
  331. void sHandler::m_HandleError()
  332. {
  333. cerr <<"Error Occurred: " <<WSAGetLastError();
  334. }
  335.  
  336. //This function handles the data that will be passed between the usr and the target also it handles the CONNECT CMD
  337. bool sHandler::m_HandleTunnel()
  338. {
  339. if (!isConnected)
  340. {
  341. //Not connected so we have to handle the CONNECT CMD
  342. this->m_BytesRead = recv(this->usrSocket,(char*)&request->m_cVer,1,0);
  343. if ((m_BytesRead < 1) || (m_BytesRead == SOCKET_ERROR))
  344. {
  345. m_HandleError();
  346. return false;
  347. }
  348. if (request->m_cVer != S_VER)
  349. {
  350. cout <<"SOCKS VER: " <<request->m_cVer <<" : " <<(int)request->m_cVer <<endl;
  351. return false;
  352. }
  353.  
  354. this->m_BytesRead = recv(this->usrSocket,(char*)&request->m_cCmd,1,0);
  355. if ((m_BytesRead < 1) || (m_BytesRead == SOCKET_ERROR))
  356. {
  357. m_HandleError();
  358. return false;
  359. }
  360. cout <<"CMD: " <<(int)request->m_cCmd <<endl;
  361.  
  362. this->m_BytesRead = recv(this->usrSocket,(char*)&request->m_cReserved,1,0);
  363. if ((m_BytesRead < 1) || (m_BytesRead == SOCKET_ERROR))
  364. {
  365. m_HandleError();
  366. return false;
  367. }
  368.  
  369. this->m_BytesRead = recv(this->usrSocket, (char*)&request->m_cAddrType,1,0);
  370. if ((m_BytesRead < 1) || (m_BytesRead == SOCKET_ERROR))
  371. {
  372. m_HandleError();
  373. return false;
  374. }
  375. cout <<"ADDR TYPE: " <<request->m_cAddrType <<" : " <<(int)request->m_cAddrType <<endl;
  376.  
  377. switch(this->request->m_cAddrType)
  378. {
  379. case S_REQ_ADDR_IPV4:
  380. cout <<"Passed IPV4" <<endl;
  381. this->m_BytesRead = recv(this->usrSocket,(char*)&request->m_szDestAddr,S_REQ_IPV4_SIZE,0);
  382. if ((m_BytesRead < S_REQ_IPV4_SIZE) || (m_BytesRead == SOCKET_ERROR))
  383. {
  384. m_HandleError();
  385. return false;
  386. }
  387. hostentry = gethostbyname(request->m_szDestAddr);
  388. break;
  389. case S_REQ_ADDR_IPV6:
  390. cout <<"Passed IPV6 Address Type" <<endl;
  391. this->m_BytesRead = recv(this->usrSocket,(char*)&request->m_szDestAddr,S_REQ_IPV6_SIZE,0);
  392. if ((m_BytesRead < S_REQ_IPV6_SIZE) || (m_BytesRead == SOCKET_ERROR))
  393. {
  394. m_HandleError();
  395. return false;
  396. }
  397. hostentry = gethostbyname(request->m_szDestAddr);
  398. break;
  399. case S_REQ_ADDR_DOMAIN:
  400.  
  401. m_BytesRead = recv(this->usrSocket,(char*)&this->tmpSize,1,0);
  402. cout <<"tmpSize is " <<(int)this->tmpSize <<endl;
  403. if ((m_BytesRead < 1) || (m_BytesRead == SOCKET_ERROR))
  404. {
  405. m_HandleError();
  406. return false;
  407. }
  408. m_BytesRead = recv(this->usrSocket,(char*)request->m_szDestAddr,(int)tmpSize,0);
  409.  
  410. if ((m_BytesRead < (int)tmpSize) || (m_BytesRead == SOCKET_ERROR))
  411. {
  412. m_HandleError();
  413. return false;
  414. }
  415. hostentry = gethostbyname(request->m_szDestAddr);
  416. cout <<"request->m_szDestAddr = " <<request->m_szDestAddr <<endl;
  417. if (hostentry == NULL)
  418. {
  419. cout <<"Unable to find host" <<endl;
  420. return false;
  421. }
  422.  
  423. break;
  424. default:
  425. cout <<"Unknown ADDR_TYPE: " <<request->m_cAddrType <<" : " <<(int)request->m_cAddrType <<endl;
  426. return false;
  427. break;
  428. }
  429.  
  430.  
  431. m_BytesRead = recv(this->usrSocket,(char*)request->m_szDestPort,2,0);
  432. if ((m_BytesRead < 2) || (m_BytesRead == SOCKET_ERROR))
  433. {
  434. m_HandleError();
  435. return false;
  436. }
  437.  
  438. //Recived all the data needed to make the Connection
  439.  
  440. switch(request->m_cCmd)
  441. {
  442. case S_REQ_CONNECT:
  443. cout <<"Connection request generated!" <<endl;
  444. dstServer.sin_family = AF_INET;
  445. dstServer.sin_addr.s_addr = *(unsigned long*)hostentry->h_addr;
  446. dstServer.sin_port = (*(unsigned short*)&request->m_szDestPort[0]);
  447.  
  448. this->m_SockErr = connect(this->dstSocket,(sockaddr*)&dstServer,sizeof(dstServer));
  449. if (this->m_SockErr == SOCKET_ERROR)
  450. {
  451. m_HandleError();
  452. return false;
  453. }
  454. reply->m_cVer = S_VER;
  455. reply->m_cReply = S_REPLY_OK;
  456. reply->m_cReserved = S_RSV;
  457. reply->m_cAddrType = S_REPLY_ADDR_IPV4;
  458.  
  459. localSize = sizeof(locallyBoundInfo);
  460. if (getsockname(dstSocket,&locallyBoundInfo,&localSize))
  461. {
  462. cout <<"can't get locally bound info" <<endl;
  463. }
  464. cout <<"SA DATA " <<(int)locallyBoundInfo.sa_data <<endl;
  465. memcpy(reply->m_szBindAddr,&locallyBoundInfo.sa_data+2,4);
  466. memcpy(reply->m_szBindPort,&locallyBoundInfo.sa_data,2);
  467.  
  468. this->m_BytesRead = send(usrSocket,(char*)&reply->m_cVer,1,0);
  469. if (this->m_BytesRead > 1)
  470. {
  471. cout <<"More bytes than expected sent!" <<endl;
  472. }
  473. this->m_BytesRead = send(usrSocket,(char*)&reply->m_cReply,1,0);
  474. if (this->m_BytesRead > 1)
  475. {
  476. cout <<"More bytes than expected sent!" <<endl;
  477. }
  478. this->m_BytesRead = send(usrSocket,(char*)&reply->m_cReserved,1,0);
  479. if (this->m_BytesRead > 1)
  480. {
  481. cout <<"More bytes than expected sent!" <<endl;
  482. }
  483. this->m_BytesRead = send(usrSocket,(char*)&reply->m_cAddrType,1,0);
  484. if (this->m_BytesRead > 1)
  485. {
  486. cout <<"More bytes than expected sent!" <<endl;
  487. }
  488. this->m_BytesRead = send(usrSocket,(char*)&reply->m_szBindAddr,4,0);
  489. cout <<"BIND: " <<reply->m_szBindAddr <<endl;
  490. if (this->m_BytesRead > 4)
  491. {
  492. cout <<"More bytes than expected sent!" <<endl;
  493. }
  494. this->m_BytesRead = send(usrSocket,(char*)&reply->m_szBindPort,2,0);
  495. if (this->m_BytesRead > 2)
  496. {
  497. cout <<"More bytes than expected sent!" <<endl;
  498. }
  499. cout <<"Connected!" <<endl;
  500. cout <<"Tmp size is " <<(int)tmpSize <<endl;
  501. this->isConnected = true;
  502. FD_SET(dstSocket,&allSocks);
  503. FD_SET(usrSocket,&allSocks);
  504. cout <<"All Socks set to " <<allSocks.fd_count <<endl;
  505. return true;
  506.  
  507. break;
  508. case S_REQ_ADDR_DOMAIN:
  509. cout <<"Domain Request Generated" <<endl;
  510. break;
  511. case S_REQ_BIND:
  512. cout <<"Bind Request Generated" <<endl;
  513. break;
  514. default:
  515. cout <<"Not yet handled Request" <<endl;
  516. return false;
  517. break;
  518.  
  519.  
  520. }
  521.  
  522.  
  523.  
  524. }
  525. else
  526. {
  527. //Relay Data between the sockets here
  528. rdySocks = allSocks;
  529. rdyCount = select(rdySocks.fd_count,&rdySocks,NULL,NULL,&waitTime);
  530. if (rdyCount == SOCKET_ERROR)
  531. {
  532. m_HandleError();
  533. cout <<"Select()" <<endl;
  534. return false;
  535. }
  536. //cout <<rdyCount <<" sockets Ready" <<endl;
  537. if (rdyCount > 0)
  538. {
  539. for (int i = 0; i < rdyCount; i++)
  540. {
  541. cout <<"reading from " <<i <<endl;
  542. this->m_SockErr = recv(rdySocks.fd_array[i],this->tmpBuffer,256,0);
  543. if (this->m_SockErr == SOCKET_ERROR)
  544. {
  545. if (WSAGetLastError() == WSAECONNRESET)
  546. {
  547. cout <<"Connection closed becuase WSACONNRESET" <<endl;
  548. this->active = false;
  549. }
  550. else{
  551. m_HandleError();
  552. cout <<"recv[" <<i <<"]" <<endl;
  553. }
  554. }
  555. if (this->m_SockErr == 0)
  556. {
  557. cout <<"Connection Closed BECUASE 0" <<endl;
  558. this->active = false;
  559. }
  560. if (rdySocks.fd_array[i] == usrSocket)
  561. {
  562. cout <<"Recived from usrSocket" <<endl;
  563. this->m_SockErr = send(dstSocket,this->tmpBuffer,m_SockErr,0);
  564. cout <<"Sent to usrSocket" <<endl;
  565. }
  566. else
  567. {
  568. cout <<"Recieved From dstSocket" <<endl;
  569. this->m_SockErr = send(usrSocket,this->tmpBuffer,m_SockErr,0);
  570. cout <<"Send to usrSocket" <<endl;
  571. }
  572. memset(this->tmpBuffer,0,256);
  573. }
  574. }
  575.  
  576. return true;
  577. }
  578.  
  579. }
  580. [FILE = ./socksHandler/sHandler.h]
  581. #ifndef SHANDLER_H_INCLUDED
  582. #define SHANDLER_H_INCLUDED
  583.  
  584. #include "sProto.h"
  585. #include "sAuthReply.h"
  586. #include "sAuthRequest.h"
  587. #include "sReply.h"
  588. #include "sRequest.h"
  589. #include "winsock2.h"
  590. #include <iostream>
  591.  
  592. /* This class handles the SOCKS5 Protocol for an individual tunnel and controls what has happened etc.*/
  593.  
  594. using namespace std;
  595.  
  596. class sHandler {
  597.  
  598. public:
  599. sHandler(int clientSocket);
  600. ~sHandler();
  601.  
  602. void m_HandleTransfers();
  603. bool active;
  604. static unsigned int g_id;
  605. unsigned int unique_id;
  606.  
  607.  
  608.  
  609. private:
  610. bool isConnected; //This will be used to tell if the connection was successful
  611. int usrSocket; //The socket that initially requests the connection
  612. int dstSocket; //The socket that will be used to make the connection
  613. FD_SET allSocks;
  614. FD_SET rdySocks;
  615. struct timeval waitTime;
  616. sRequest *request;
  617. sReply *reply;
  618. sAuthRequest *authRequest;
  619. sAuthReply *authReply;
  620. int m_SockErr;
  621. int m_BytesRead;
  622. bool isAuthed;
  623. bool m_HandleTunnel();
  624. bool m_Validate();
  625. void m_HandleError();
  626. struct hostent *hostentry;
  627. struct sockaddr_in dstServer;
  628. char tmpSize;
  629. char tmpBuffer[256];
  630. int rdyCount;
  631. struct sockaddr locallyBoundInfo;
  632. int localSize;
  633.  
  634. };
  635.  
  636. #endif // SHANDLER_H_INCLUDED
  637. [FILE = ./socksHandler/sProto.h]
  638. #ifndef SPROTO_H_INCLUDED
  639. #define SPROTO_H_INCLUDED
  640.  
  641. //This file contains all of the SOCKS5 Protocol constants and will be included in just about every file.
  642. //This is the SOCKS version and will always be 5 for a SOCKS5 server
  643. #define S_VER 5
  644.  
  645. //These are the possible SOCKS 5 Server authentication methods
  646. //This server will always use no auth but just for possible future expansion I'm including all the possible auth. methods
  647. #define S_NO_AUTH_REQ 0
  648. #define S_GSSAPI 1
  649. #define S_USERPASS 2
  650. #define S_IANA_ASS_BEG 3
  651. #define S_IANA_ASS_END 127
  652. #define S_PRIVATE_BEG 128
  653. #define S_PRIVATE_END 254
  654. #define S_NO_OK_METHOD 255
  655.  
  656. //These are the Request constants
  657. #define S_REQ_CONNECT 1
  658. #define S_REQ_BIND 2
  659. #define S_REQ_UDP_ASSOC 3
  660.  
  661. #define S_REQ_ADDR_IPV4 1
  662. #define S_REQ_ADDR_IPV6 4
  663. #define S_REQ_ADDR_DOMAIN 3
  664.  
  665. #define S_REQ_IPV4_SIZE 4
  666. #define S_REQ_IPV6_SIZE 16
  667.  
  668. //No define for domain b/c the 1st octect indicates the size of the domain that immediately follows, no terminating null
  669.  
  670. //RESERVED WILL ALWAYS BE \x00 So we define it
  671. #define S_RSV 0
  672. //These are the Reply constants that are used
  673. #define S_REPLY_OK 0
  674. #define S_REPLY_GENERAL_FAIL 1
  675. #define S_REPLY_NOT_ALLOWED 2
  676. #define S_REPLY_NET_UNREACHABLE 3
  677. #define S_REPLY_HOST_UNREACHABLE 4
  678. #define S_REPLY_CONN_REFUSED 5
  679. #define S_REPLY_TTL_EXP 6
  680. #define S_REPLY_CMD_NOT_SUPPORTED 7
  681. #define S_REPLY_ADDR_NOT_SUPPORTED 8
  682.  
  683. #define S_REPLY_ADDR_IPV4 1
  684. #define S_REPLY_ADDR_IPV6 4
  685. #define S_REPLY_ADDR_DOMAIN 3
  686.  
  687.  
  688. #endif // SPROTO_H_INCLUDED
  689. [FILE = ./socksHandler/sReply.cpp]
  690. #include "sReply.h"
  691.  
  692. sReply::sReply()
  693. {
  694. this->m_cAddrType = '\0';
  695. this->m_cReply = '\0';
  696. this->m_cReserved = S_RSV;
  697. this->m_cVer = S_VER;
  698. memset(this->m_szBindAddr,0,sizeof(this->m_szBindAddr));
  699. memset(this->m_szBindPort,0,sizeof(this->m_szBindPort));
  700.  
  701. }
  702.  
  703. sReply::~sReply()
  704. {
  705.  
  706. }
  707. [FILE = ./socksHandler/sReply.h]
  708. #ifndef SREPLY_H_INCLUDED
  709. #define SREPLY_H_INCLUDED
  710.  
  711. #include "sProto.h"
  712. #include <cstring>
  713.  
  714. class sReply
  715. {
  716. public:
  717. sReply();
  718. ~sReply();
  719.  
  720. char m_cVer;
  721. char m_cReply;
  722. char m_cReserved;
  723. char m_cAddrType;
  724. char m_szBindAddr[256];
  725. char m_szBindPort[2];
  726.  
  727.  
  728. };
  729.  
  730.  
  731. #endif // SREPLY_H_INCLUDED
  732. [FILE = ./socksHandler/sRequest.cpp]
  733. #include "sRequest.h"
  734.  
  735. sRequest::sRequest()
  736. {
  737. this->m_cAddrType = '\0';
  738. this->m_cCmd = '\0';
  739. this->m_cReserved = S_RSV;
  740. this->m_cVer = S_VER;
  741. memset(this->m_szDestAddr,0,256);
  742. memset(this->m_szDestPort,0,2);
  743. }
  744.  
  745. sRequest::~sRequest()
  746. {
  747.  
  748. }
  749. [FILE = ./socksHandler/sRequest.h]
  750. #ifndef SREQUEST_H_INCLUDED
  751. #define SREQUEST_H_INCLUDED
  752.  
  753. #include "sProto.h"
  754. #include <cstring>
  755.  
  756. class sRequest {
  757.  
  758. public:
  759. sRequest();
  760. ~sRequest();
  761.  
  762. char m_cVer;
  763. char m_cCmd;
  764. char m_cReserved;
  765. char m_cAddrType;
  766. char m_szDestAddr[256];
  767. char m_szDestPort[2];
  768. };
  769.  
  770.  
  771. #endif // SREQUEST_H_INCLUDED
  772.  
Return to cpp category list

Who Visited EnigmaGroup Today?

1520 Guests, 298 Users (192 Spiders)
spartanvedicrishi, BlAd373, myfabregas, DrOptix, g3nu1n3, saraf, VireekadiaFap, obencefoozy, memoryshot, mongrel88, drag0n, Kearstin29, litbk, alexelixir, r0z4, Abhinav2107, theanonymous21, greatg, CreedoFiegree, bivaEmilltite, posthuman01, Taireegaddita, Taicadine, c_a13, hizImmoli, scifics, slchill, KELATALFTUS, kynapse, Tonyui, Hackpad, Epilioptiop, Mamorite, IodindDog, brunoriversyhn, Effomeidonize, ReottphoffBom, arktek, burgeoningneophyte, TradaGreant, SlayingDragons, Waldlyeps, Arsenal, CJ_Omaha, Ryuske, thethird3y3, todayadvila, pwnpwnlolz, NeetaexomYgom, ookami-namikaze, dot_Cipher, Unotohumsmush, SaubymorRoyab, loltyg, Ausome1, Rik, hrangel, cyber-guard, Meonkzt, mori, 31415926, optioniLele, intorerse, FlifobbyFloks, Ios, Røgue, cossyDrybrich, IvanDimitriev, havisham, KIKNWING, fitz, fleeloCycle, hackboy302, strudels, CootoDorbeeft, gymnediny, hustleman9tv, comando300, Ysri13, thatoneguy, Paran0id, whoami, Pitanteerve, Reapon, cls777, Afrika, suetekh, somebody777, floontiny, Frudopvia, jasonbourne, zombiehack640, CloverCipher, spoosh, Fraubbova, rulebreaker, dncjor, Fintyoptots, viRuleNt, NipPaineHainy, TheHarrisonW, Jamesgo, TheGanjator, psychomarine, 1421carter, tingle65, claudius, Feld Grau, Partisan, Gunslinger, gydeqqzpn, yshiau, Zaccarato, chromoSone, priovasashCor, ellisp, GothicLogic, keetone, M0rdak, UsedDeteKef, nhorton, archestraty, HatriteBeft, JC06dc5, alpha1, spg, dark_void, wakazi, mtroscheck, TheCheeseDemon, ach.n30, sahariar, hervelegeraf, Psiber_Syn, hackaday, Mod777, neompenly, pollolololo, SnoopSky, Cigmimifs, ProloG-Shaman, unicornrainbow, cheapnikeshoxog, bobsters, foofthoorgo, polemarchos, avacraft, spencerwilliams23, lotato, ryanjcrook, dollerolf, robintenboden, rospark, WexEmbet, BeefSupreme, Hessesian, whydoyoulook, cdpirate, DnA-Ender, CaNcEr, zheincnoob, Vengeance987, justforfun363, RawTeefecycle, Squissesk, aVoid, SaMTHG, neodude, Marion1p, Ops, ddxc, Klosse, khamhou, samsatHD80, PauffPubadvic, AnnaNoult, SexyCreerve, newb1, robster1977, Blizer, Dudleypagrove, Mr_KaLiMaN, FirewallPenetrator, GMo, Seasharp, mrchicken1, Zaxem, N4g4c3N, MaxMeier, Ian, sander.ashwin, Predatorc, lonely.connection, ElEnfermado, wavyd, dirkdanblue, cve916, kalak55, a1los, jell0, Exclaw, veceattainc, Muselele, Mr Pacifist, stylish007, zach, closednetwork99, soroimmuror, PlaneReaction, Wamemanytex38, DieAble, d0seN_36b, jeremy.whitson, lol, nefeolnb, Noticon, statix, anandoump, RomeoG, advilapyday, snorapa, Gkjt, autotuneuser, beanulpinee, 2142, kiklopas, door51, Pizza, deepakkumar, makler2004, M4rcy, Xargos, bdkoenig, Blavatsky, m4f10, Huasca, itsme, xu_lain, Nikhil, ChewBigRed, samxoxo, incicaMaidits, toudioria, Chidokage, Jigoku, cesecyclelm, schn1ffl3r, sam20000, learning, kentora, San Marino, Nightraven, zanydouner, FrofErrodslot, FatalEror, wheaties, akki, AlexDiru, unclejos666, override101, blink_212, uncowstientee, lilkpoigogs, Innonaenupt607, Killshot, ZheIncKnight, ActictGlync, acarseflalk, ___, trashsporn, Memartent, Zoorsornaks, z3z3, heyhey123, Ghajnm, usaliaPels, Ordeptpen, pelly, quellense, Szuba, nmobin27, lamb, x1rt4m, ToutousaRulty, vipervince2002, mannavard1611, BinaryShinigami, Duchdund, afgnumgt, Anatissa, darkfire1515, bennyblanco5000, Mmmett50, ToryLogsEsoff, impalwinona, Kelsfednege, ensubbrut, ant0601
 
Enigma Group