INET Framework for OMNeT++/OMNEST
inet::httptools::HttpServerEvilB Class Reference

An evil attacker server demonstration - type B. More...

#include <HttpServerEvilB.h>

Inheritance diagram for inet::httptools::HttpServerEvilB:
inet::httptools::HttpServer inet::httptools::HttpServerBase inet::TCPSocket::CallbackInterface inet::httptools::HttpNodeBase inet::ILifecycle

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual std::string generateBody () override
 
- Protected Member Functions inherited from inet::httptools::HttpServer
virtual void finish () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void socketEstablished (int connId, void *yourPtr) override
 
virtual void socketDataArrived (int connId, void *yourPtr, cPacket *msg, bool urgent) override
 
virtual void socketPeerClosed (int connId, void *yourPtr) override
 
virtual void socketClosed (int connId, void *yourPtr) override
 
virtual void socketFailure (int connId, void *yourPtr, int code) override
 
- Protected Member Functions inherited from inet::httptools::HttpServerBase
virtual void refreshDisplay () const override
 
HttpReplyMessagegenerateDocument (HttpRequestMessage *request, const char *resource, int size=0)
 
HttpReplyMessagegenerateResourceMessage (HttpRequestMessage *request, std::string resource, HttpContentType category)
 
HttpReplyMessagehandleGetRequest (HttpRequestMessage *request, std::string resource)
 
HttpReplyMessagegenerateErrorReply (HttpRequestMessage *request, int code)
 
cPacket * handleReceivedMessage (cMessage *msg)
 
void registerWithController ()
 
void readSiteDefinition (std::string file)
 
std::string readHtmlBodyFile (std::string file, std::string path)
 
- Protected Member Functions inherited from inet::httptools::HttpNodeBase
void sendDirectToModule (HttpNodeBase *receiver, cPacket *packet, simtime_t constdelay=0.0, rdObject *rd=nullptr)
 
double transmissionDelay (cPacket *packet)
 
void logRequest (const HttpRequestMessage *httpRequest)
 
void logResponse (const HttpReplyMessage *httpResponse)
 
void logEntry (std::string line)
 
std::string formatHttpRequestShort (const HttpRequestMessage *httpRequest)
 
std::string formatHttpResponseShort (const HttpReplyMessage *httpResponse)
 
std::string formatHttpRequestLong (const HttpRequestMessage *httpRequest)
 
std::string formatHttpResponseLong (const HttpReplyMessage *httpResponse)
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 

Private Attributes

int badLow = 0
 
int badHigh = 0
 

Additional Inherited Members

- Public Member Functions inherited from inet::httptools::HttpServerBase
 HttpServerBase ()
 
 ~HttpServerBase ()
 
const std::string & getHostName ()
 
- Public Member Functions inherited from inet::httptools::HttpNodeBase
 HttpNodeBase ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Public Member Functions inherited from inet::TCPSocket::CallbackInterface
virtual ~CallbackInterface ()
 
virtual void socketStatusArrived (int connId, void *yourPtr, TCPStatusInfo *status)
 
virtual void socketDeleted (int connId, void *yourPtr)
 
- Protected Attributes inherited from inet::httptools::HttpServer
TCPSocket listensocket
 
TCPSocketMap sockCollection
 
unsigned long numBroken = 0
 
unsigned long socketsOpened = 0
 
- Protected Attributes inherited from inet::httptools::HttpServerBase
std::string hostName
 
int port = -1
 
bool scriptedMode = false
 
std::map< std::string, HtmlPageDatahtmlPages
 
std::map< std::string, unsigned int > resources
 
simtime_t activationTime
 
long htmlDocsServed = 0
 
long imgResourcesServed = 0
 
long textResourcesServed = 0
 
long badRequests = 0
 
rdObjectrdReplyDelay = nullptr
 The processing delay of the server. More...
 
rdObjectrdHtmlPageSize = nullptr
 The HTML page size distribution for the site. More...
 
rdObjectrdTextResourceSize = nullptr
 The text resource size distribution for the site. More...
 
rdObjectrdImageResourceSize = nullptr
 The image resource size distribution for the site. More...
 
rdObjectrdNumResources = nullptr
 Number of resources per HTML page. More...
 
rdObjectrdTextImageResourceRatio = nullptr
 The ratio of text resources to images referenced in HTML pages. More...
 
rdObjectrdErrorMsgSize = nullptr
 The size of error messages. More...
 
- Protected Attributes inherited from inet::httptools::HttpNodeBase
unsigned long linkSpeed = 0
 
int httpProtocol = 0
 
std::string logFileName
 
bool enableLogging = true
 
LOG_FORMAT outputFormat = lf_short
 
bool m_bDisplayMessage = true
 
bool m_bDisplayResponseContent = true
 
cModule * host = nullptr
 

Detailed Description

An evil attacker server demonstration - type B.

Demonstrates subclassing the server to create a custom site. This site is an attacker – a puppetmaster – which serves HTML pages containing attack code. In this case, we are simulating JavaScript attack code which prompts the unsuspecting browser to issue a number of requests for non-existing resources (random URLs) to the victim site. Delays are specified to simulate hiding the attack from the browser user by use of JavaScript timeouts or similar mechanisms. The generateBody virtual function is redefined to create a page containing the attack code.

See also
HttpServer
Author
Kristjan V. Jonsson

Member Function Documentation

std::string inet::httptools::HttpServerEvilB::generateBody ( )
overrideprotectedvirtual

Reimplemented from inet::httptools::HttpServerBase.

40 {
41  int numResources = badLow + (int)uniform(0, badHigh - badLow);
42  double rndDelay;
43  std::string result;
44 
45  char tempBuf[128];
46  int refSize;
47  for (int i = 0; i < numResources; i++) {
48  rndDelay = 10.0 + uniform(0, 2.0);
49  refSize = (int)uniform(500, 1000); // The random size represents a random reference string length
50  sprintf(tempBuf, "TEXT%.4d.txt;%s;%f;%s;%d\n", i, "www.good.com", rndDelay, "TRUE", refSize);
51  result.append(tempBuf);
52  }
53 
54  return result;
55 }
int badLow
Definition: HttpServerEvilB.h:44
int badHigh
Definition: HttpServerEvilB.h:45
void inet::httptools::HttpServerEvilB::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::httptools::HttpServer.

27 {
29 
30  if (stage == INITSTAGE_LOCAL) {
31  badLow = par("minBadRequests");
32  badHigh = par("maxBadRequests");
33 
34  EV_INFO << "Badguy " << hostName << " was initialized to launch an attack on www.good.com" << endl;
35  EV_INFO << "Minimum " << badLow << " and maximum " << badHigh << " bad requests for each hit." << endl;
36  }
37 }
int badLow
Definition: HttpServerEvilB.h:44
std::string hostName
Definition: HttpServerBase.h:63
int badHigh
Definition: HttpServerEvilB.h:45
Local initializations.
Definition: InitStages.h:35
virtual void initialize(int stage) override
Definition: HttpServer.cc:26
virtual int inet::httptools::HttpServerEvilB::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::httptools::HttpServer.

48 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116

Member Data Documentation

int inet::httptools::HttpServerEvilB::badHigh = 0
private

Referenced by generateBody(), and initialize().

int inet::httptools::HttpServerEvilB::badLow = 0
private

Referenced by generateBody(), and initialize().


The documentation for this class was generated from the following files: