| 209 | | Message *Msg = new Message((char *)m_Buffer->getData(), m_Buffer->getSize(),m_Socket->getLocalPort(), m_Socket->getRemotePort(), |
|---|
| 210 | | m_Socket->getLocalHost(), m_Socket->getRemoteHost(), m_Socket, m_Socket); |
|---|
| 211 | | if ( g_Nepenthes->getShellcodeMgr()->handleShellcode(&Msg) == SCH_DONE ) |
|---|
| 212 | | { |
|---|
| 213 | | msg->getResponder()->doRespond("found encrypt0r\n",strlen("found encrypt0r\n")); |
|---|
| 214 | | m_Buffer->clear(); |
|---|
| | 190 | if ( m_Buffer->getSize() > 0xcd0 ) |
|---|
| | 191 | { |
|---|
| | 192 | Message *Msg = new Message((char *)m_Buffer->getData(), m_Buffer->getSize(),m_Socket->getLocalPort(), m_Socket->getRemotePort(), |
|---|
| | 193 | m_Socket->getLocalHost(), m_Socket->getRemoteHost(), m_Socket, m_Socket); |
|---|
| | 194 | sch_result sch; |
|---|
| | 195 | sch = g_Nepenthes->getShellcodeMgr()->handleShellcode(&Msg); |
|---|
| | 196 | delete Msg; |
|---|
| | 197 | |
|---|
| | 198 | if ( sch == SCH_DONE ) |
|---|
| | 199 | { |
|---|
| | 200 | m_Buffer->clear(); |
|---|
| | 201 | return CL_ASSIGN_AND_DONE; |
|---|
| | 202 | } |
|---|
| | 203 | |
|---|
| 219 | | */ |
|---|
| 220 | | |
|---|
| 221 | | char *message = (char *)malloc(msg->getSize()+1); |
|---|
| 222 | | memset(message,0,msg->getSize()+1); |
|---|
| 223 | | memcpy(message,msg->getMsg(),msg->getSize()); |
|---|
| 224 | | |
|---|
| 225 | | for(uint32_t i=0;i < strlen(message);i++) |
|---|
| 226 | | { |
|---|
| 227 | | if(!isgraph(message[i]) && message[i] != ' ') |
|---|
| 228 | | { |
|---|
| 229 | | message[i] = ' '; |
|---|
| 230 | | } |
|---|
| | 207 | } |
|---|
| | 208 | |
|---|
| | 209 | /** |
|---|
| | 210 | * Dialogue::outgoingData(Message *) |
|---|
| | 211 | * as we are not interested in these socket actions |
|---|
| | 212 | * we simply return CL_DROP to show the socket |
|---|
| | 213 | * |
|---|
| | 214 | * @param msg |
|---|
| | 215 | * |
|---|
| | 216 | * @return CL_DROP |
|---|
| | 217 | */ |
|---|
| | 218 | ConsumeLevel SAVDialogue::outgoingData(Message *msg) |
|---|
| | 219 | { |
|---|
| | 220 | return CL_ASSIGN; |
|---|
| | 221 | } |
|---|
| | 222 | |
|---|
| | 223 | /** |
|---|
| | 224 | * Dialogue::handleTimeout(Message *) |
|---|
| | 225 | * as we are not interested in these socket actions |
|---|
| | 226 | * we simply return CL_DROP to show the socket |
|---|
| | 227 | * |
|---|
| | 228 | * @param msg |
|---|
| | 229 | * |
|---|
| | 230 | * @return CL_DROP |
|---|
| | 231 | */ |
|---|
| | 232 | ConsumeLevel SAVDialogue::handleTimeout(Message *msg) |
|---|
| | 233 | { |
|---|
| | 234 | return CL_DROP; |
|---|
| | 235 | } |
|---|
| | 236 | |
|---|
| | 237 | /** |
|---|
| | 238 | * Dialogue::connectionLost(Message *) |
|---|
| | 239 | * as we are not interested in these socket actions |
|---|
| | 240 | * we simply return CL_DROP to show the socket |
|---|
| | 241 | * |
|---|
| | 242 | * @param msg |
|---|
| | 243 | * |
|---|
| | 244 | * @return CL_DROP |
|---|
| | 245 | */ |
|---|
| | 246 | ConsumeLevel SAVDialogue::connectionLost(Message *msg) |
|---|
| | 247 | { |
|---|
| | 248 | return CL_DROP; |
|---|
| | 249 | } |
|---|
| | 250 | |
|---|
| | 251 | /** |
|---|
| | 252 | * Dialogue::connectionShutdown(Message *) |
|---|
| | 253 | * as we are not interested in these socket actions |
|---|
| | 254 | * we simply return CL_DROP to show the socket |
|---|
| | 255 | * |
|---|
| | 256 | * @param msg |
|---|
| | 257 | * |
|---|
| | 258 | * @return CL_DROP |
|---|
| | 259 | */ |
|---|
| | 260 | ConsumeLevel SAVDialogue::connectionShutdown(Message *msg) |
|---|
| | 261 | { |
|---|
| | 262 | return CL_DROP; |
|---|
| | 263 | } |
|---|
| | 264 | |
|---|
| | 265 | |
|---|
| | 266 | |
|---|
| | 267 | |
|---|
| | 268 | extern "C" int32_t module_init(int32_t version, Module **module, Nepenthes *nepenthes) |
|---|
| | 269 | { |
|---|
| | 270 | if ( version == MODULE_IFACE_VERSION ) |
|---|
| | 271 | { |
|---|
| | 272 | *module = new VulnSAV(nepenthes); |
|---|
| | 273 | return (1); |
|---|
| | 274 | } else |
|---|
| | 275 | { |
|---|
| | 276 | return (0); |
|---|
| 232 | | |
|---|
| 233 | | #ifdef WIN32 |
|---|
| 234 | | char *cmd = message; |
|---|
| 235 | | #else |
|---|
| 236 | | char *cmd = strsep(&message, " "); |
|---|
| 237 | | #endif |
|---|
| 238 | | |
|---|
| 239 | | if( !strncmp(cmd, "download",8) ) |
|---|
| 240 | | { |
|---|
| 241 | | |
|---|
| 242 | | uint8_t downloadflags=0; |
|---|
| 243 | | if (strcmp(cmd,"downloadbinary") == 0) |
|---|
| 244 | | { |
|---|
| 245 | | downloadflags |= DF_TYPE_BINARY; |
|---|
| 246 | | } |
|---|
| 247 | | |
|---|
| 248 | | #ifdef WIN32 |
|---|
| 249 | | char *url = "http://test.de/"; |
|---|
| 250 | | #else |
|---|
| 251 | | char *url = strsep(&message, " "); |
|---|
| 252 | | #endif |
|---|
| 253 | | logCrit("Downloading file from \"%s\"\n", url); |
|---|
| 254 | | |
|---|
| 255 | | msg->getSocket()->getNepenthes()->getDownloadMgr()->downloadUrl(msg->getLocalHost(),url, msg->getRemoteHost(), msg->getMsg(),downloadflags); |
|---|
| 256 | | |
|---|
| 257 | | string sDeineMutter("trying to download file\n"); |
|---|
| 258 | | msg->getResponder()->doRespond((char *)sDeineMutter.c_str(),sDeineMutter.size()); |
|---|
| 259 | | |
|---|
| 260 | | } |
|---|
| 261 | | |
|---|
| 262 | | // msg->getResponder()->doRespond("deine mutter\n",strlen("deine mutter\n")); |
|---|
| 263 | | return CL_ASSIGN; |
|---|
| 264 | | |
|---|
| 265 | | /* |
|---|
| 266 | | string command(msg->getMsg(),msg->getSize()); |
|---|
| 267 | | |
|---|
| 268 | | unsigned int offset; |
|---|
| 269 | | if (((offset = command.find("list"))) < command.size() ) |
|---|
| 270 | | { |
|---|
| 271 | | int fd; |
|---|
| 272 | | |
|---|
| 273 | | for (fd=0;fd<64*1024;fd++) |
|---|
| 274 | | { |
|---|
| 275 | | int32_t iError = 0; |
|---|
| 276 | | int32_t iSize = sizeof(iError); |
|---|
| 277 | | |
|---|
| 278 | | |
|---|
| 279 | | if (getsockopt(fd,SOL_SOCKET, SO_ERROR, &iError,(socklen_t *) &iSize) == 0 ) |
|---|
| 280 | | { |
|---|
| 281 | | if (iError != 0) |
|---|
| 282 | | continue; |
|---|
| 283 | | |
|---|
| 284 | | struct sockaddr_in addrLocal; |
|---|
| 285 | | iSize = sizeof(addrLocal); |
|---|
| 286 | | |
|---|
| 287 | | if ( getsockname(fd, (struct sockaddr *) &addrLocal, (socklen_t *) &iSize) != 0 ) |
|---|
| 288 | | continue; |
|---|
| 289 | | |
|---|
| 290 | | struct sockaddr_in addrRemote; |
|---|
| 291 | | iSize = sizeof(addrRemote); |
|---|
| 292 | | if ( getpeername(fd, (struct sockaddr *) &addrRemote, (socklen_t *) &iSize) != 0 ) |
|---|
| 293 | | continue; |
|---|
| 294 | | |
|---|
| 295 | | |
|---|
| 296 | | string localhost,remotehost; |
|---|
| 297 | | |
|---|
| 298 | | localhost = inet_ntoa(*(struct in_addr *)&((sockaddr_in)addrLocal).sin_addr); |
|---|
| 299 | | remotehost = inet_ntoa(*(struct in_addr *)&((sockaddr_in)addrRemote).sin_addr); |
|---|
| 300 | | |
|---|
| 301 | | logInfo("%i %-15s -> %-15s\n",fd,localhost.c_str(),remotehost.c_str()); |
|---|
| 302 | | |
|---|
| 303 | | close(fd); |
|---|
| 304 | | } |
|---|
| 305 | | } |
|---|
| 306 | | } |
|---|
| 307 | | |
|---|
| 308 | | return CL_ASSIGN; |
|---|
| 309 | | */ |
|---|
| 310 | | } |
|---|
| 311 | | |
|---|
| 312 | | /** |
|---|
| 313 | | * Dialogue::outgoingData(Message *) |
|---|
| 314 | | * as we are not interested in these socket actions |
|---|
| 315 | | * we simply return CL_DROP to show the socket |
|---|
| 316 | | * |
|---|
| 317 | | * @param msg |
|---|
| 318 | | * |
|---|
| 319 | | * @return CL_DROP |
|---|
| 320 | | */ |
|---|
| 321 | | ConsumeLevel X2Dialogue::outgoingData(Message *msg) |
|---|
| 322 | | { |
|---|
| 323 | | return CL_ASSIGN; |
|---|
| 324 | | } |
|---|
| 325 | | |
|---|
| 326 | | /** |
|---|
| 327 | | * Dialogue::handleTimeout(Message *) |
|---|
| 328 | | * as we are not interested in these socket actions |
|---|
| 329 | | * we simply return CL_DROP to show the socket |
|---|
| 330 | | * |
|---|
| 331 | | * @param msg |
|---|
| 332 | | * |
|---|
| 333 | | * @return CL_DROP |
|---|
| 334 | | */ |
|---|
| 335 | | ConsumeLevel X2Dialogue::handleTimeout(Message *msg) |
|---|
| 336 | | { |
|---|
| 337 | | return CL_DROP; |
|---|
| 338 | | } |
|---|
| 339 | | |
|---|
| 340 | | /** |
|---|
| 341 | | * Dialogue::connectionLost(Message *) |
|---|
| 342 | | * as we are not interested in these socket actions |
|---|
| 343 | | * we simply return CL_DROP to show the socket |
|---|
| 344 | | * |
|---|
| 345 | | * @param msg |
|---|
| 346 | | * |
|---|
| 347 | | * @return CL_DROP |
|---|
| 348 | | */ |
|---|
| 349 | | ConsumeLevel X2Dialogue::connectionLost(Message *msg) |
|---|
| 350 | | { |
|---|
| 351 | | return CL_DROP; |
|---|
| 352 | | } |
|---|
| 353 | | |
|---|
| 354 | | /** |
|---|
| 355 | | * Dialogue::connectionShutdown(Message *) |
|---|
| 356 | | * as we are not interested in these socket actions |
|---|
| 357 | | * we simply return CL_DROP to show the socket |
|---|
| 358 | | * |
|---|
| 359 | | * @param msg |
|---|
| 360 | | * |
|---|
| 361 | | * @return CL_DROP |
|---|
| 362 | | */ |
|---|
| 363 | | ConsumeLevel X2Dialogue::connectionShutdown(Message *msg) |
|---|
| 364 | | { |
|---|
| 365 | | return CL_DROP; |
|---|
| 366 | | } |
|---|
| 367 | | |
|---|
| 368 | | |
|---|
| 369 | | |
|---|
| 370 | | |
|---|
| 371 | | #ifdef WIN32 |
|---|
| 372 | | extern "C" int32_t __declspec(dllexport) module_init(int32_t version, Module **module, Nepenthes *nepenthes) |
|---|
| 373 | | #else |
|---|
| 374 | | extern "C" int32_t module_init(int32_t version, Module **module, Nepenthes *nepenthes) |
|---|
| 375 | | #endif |
|---|
| 376 | | |
|---|
| 377 | | { |
|---|
| 378 | | if (version == MODULE_IFACE_VERSION) { |
|---|
| 379 | | *module = new X2(nepenthes); |
|---|
| 380 | | return 1; |
|---|
| 381 | | } else { |
|---|
| 382 | | return 0; |
|---|
| 383 | | } |
|---|
| 384 | | } |
|---|
| | 278 | } |
|---|