libcod
server.hpp
Go to the documentation of this file.
1 #ifndef _GSC_SERVER_HPP_
2 #define _GSC_SERVER_HPP_
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 /* default stuff */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 
13 /* va_args */
14 #include <stdarg.h>
15 
16 /* cdecl_injected_closer() */
17 #include "gsc.hpp"
18 
19 
20 #include <dlfcn.h>
21 
22 #include <pthread.h>
23 
24 // for getpid()
25 #include <sys/types.h>
26 #include <unistd.h> // also for usleep()
27 
28 // for time()
29 #include <time.h>
30 
31 
32 #include <inttypes.h> // int16_t
33 
34 
35 // NET
36 #include <sys/types.h>
37 #include <sys/socket.h>
38 #include <netinet/in.h>
39 #include <arpa/inet.h>
40 #include <unistd.h>
41 #include <stdlib.h>
42 #include <stdio.h>
43 #include <string.h>
44 
45 #include <sys/mman.h> /* mprotect */
46 
47 #include "cracking.hpp"
48 
49 typedef struct
50 {
53  struct sockaddr_in address;
54  socklen_t addrlen;
56 
57 
58 #define BUFFER_OUT 4096
59 
60 void startServerAsThread(int port, int debug);
61 
62 static void mythread(void *arg);
63 
64 int cdecl_injected_shell(int a, int b, int c);
65 int cdecl_return_0();
66 int cdecl_return_1();
67 int cdecl_print(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9);
68 
69 
70 
71 int TCP_server_start(TCP_connection *conn, int port);
74 int TCP_read_all_bugged(TCP_connection *conn, void *buffer, int bufferLen, int *outMsgLen);
75 int TCP_read_all(TCP_connection *conn, void *buffer, int bufferLen, int *outMsgLen);
76 int TCP_write(TCP_connection *conn, const char *str, ...);
77 
78 #define MAX_ROWS 16
79 #define MAX_COLS 16
80 #define MAX_CHARS 64
81 int parseRequest(char *toParse, char table[MAX_ROWS][MAX_COLS][MAX_CHARS]);
82 int handleRequest(char lol[MAX_ROWS][MAX_COLS][MAX_CHARS]);
83 
84 void input(char *buffer, int len);
85 
86 // now in cracking.hpp
87 //int singleHexToNumber(char hexchar);
88 //int hexToBuffer(char *hex, char *buffer, int bufferLen);
89 
90 int readMemoryRange(void *from, void *buffer, int bytes);
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif
97 
98 
99 
#define MAX_COLS
Definition: server.hpp:79
#define MAX_ROWS
Definition: server.hpp:78
int cdecl_return_0()
int cdecl_injected_shell(int a, int b, int c)
int create_socket
Definition: server.hpp:51
#define MAX_CHARS
Definition: server.hpp:80
int TCP_read_all_bugged(TCP_connection *conn, void *buffer, int bufferLen, int *outMsgLen)
socklen_t addrlen
Definition: server.hpp:54
Definition: server.hpp:49
void input(char *buffer, int len)
int TCP_server_start(TCP_connection *conn, int port)
int parseRequest(char *toParse, char table[MAX_ROWS][MAX_COLS][MAX_CHARS])
int readMemoryRange(void *from, void *buffer, int bytes)
int TCP_read_all(TCP_connection *conn, void *buffer, int bufferLen, int *outMsgLen)
int cdecl_print(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
int new_socket
Definition: server.hpp:52
void startServerAsThread(int port, int debug)
int TCP_wait_for_client(TCP_connection *conn)
int TCP_write(TCP_connection *conn, const char *str,...)
int cdecl_return_1()
int TCP_close_connection(TCP_connection *conn)
int handleRequest(char lol[MAX_ROWS][MAX_COLS][MAX_CHARS])