Class CSpoofSocket Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: Custom Code in Source After IncludesNext page: m_aConnectedTo    Show member index
Class Declared in:
SpoofSocket.h

'Overview' icon -- Shortcut to top of page. Overview

Copyright (c) 2000-2003 Barak Weichselbaum <barak@komodia.com> All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Contact info:

Site:                  http://www.komodia.com Main contact:          barak@komodia.com For custom projects, consulting, or other paid services:         sales@komodia.com

Hierarchy Chart Hierarchy Chart

'Base Classes' icon -- Shortcut to top of page. Base Classes

Public base class virtual CSpoofBase

'Data Items' icon -- Shortcut to top of page. Data Items

Private data sockaddr_in m_aConnectedTo Remote address we are conencted to
Private data SOCKET m_aSpoofSocket The actual socket handle
Private data BOOL m_bOptions Do we have options
Private data BOOL m_bOverlapped Are we an ovelapped socket
Private data BOOL m_bRaw Are we raw ?
Private data BOOL m_bSniffing Are we sniffing
Private data CIPOptions * m_pIPOptions Our options
Private data unsigned char m_ucProtocol The protocol
Private data unsigned char m_ucTTL Time to live
Private data IP m_ulSourceAddress Our source address

'Constructors' icon -- Shortcut to top of page. Constructors

Private constructor

CSpoofSocket( const CSpoofSocket& rSocket )

No copy Ctor
Protected constructor

CSpoofSocket( SOCKET aSocket )

Attach to a socket by constructor
Public constructor

CSpoofSocket( BOOL bRawSocket )

Ctor and Dtor

'Destructors' icon -- Shortcut to top of page. Destructors

Public destructor virtual

~CSpoofSocket()

'Functions' icon -- Shortcut to top of page. Functions

Protected function void

AssignSocket( SOCKET aNewSocket, unsigned char ucProtocol=IPPROTO_TCP )

Attach to a socket
Public function virtual BOOL

Bind( const std::string& rSourceAddress, unsigned short usPort )

Bind to a specific address
Public function virtual BOOL

Bind( IP aSourceAddress, unsigned short usPort )

Public function static unsigned short

CalculateChecksum( const unsigned short* pBuffer, int iSize )

Calculate the data checksum
Public function unsigned short

CalculatePseudoChecksum( const char* pBuffer, int iBufferLength, IP aDestinationAddress, int iPacketLength ) const

Calculate the checksum for TCP and UDP
Public function BOOL

CanRead() const

Check if socket if ready for reading
Public function BOOL

CanWrite() const

Check if socket if ready for writing
Protected function BOOL

CheckSocketValid() const

Check this socket is valid
Public function virtual BOOL

Close()

Close the socket
Protected function virtual LPIpHeader

ConstructIPHeader( unsigned char ucProtocol, unsigned short usFragmentationFlags, unsigned char ucTTL, unsigned short usIdentification, unsigned char ucHeaderLength ) const

Create an IP header
Public function static LPIpHeader

ConstructStaticIPHeader( unsigned char ucProtocol, unsigned short usFragmentationFlags, unsigned char ucTTL, unsigned short usIdentification, unsigned char ucHeaderLength )

Create an IP header
Public function BOOL

Create( int iProtocol )

Create a socket
Protected function virtual void

FinalIPHeader( LPIpHeader lpHead ) const

Last stop before sending the header
Public function SOCKET

GetHandle() const

Get the socket handle
Public function CIPOptions *

GetOptions() const

Get the IP options
Public function long

GetPeerAddress() const

Get the address of the remote connected system
Public function unsigned short

GetPeerPort() const

Get the port if the remote connected system
Protected function unsigned char

GetProtocol() const

Get the protocol
Protected function IP

GetSourceAddress() const

Get the source address
Protected function unsigned char

GetTTL() const

Get the TTL
Protected function BOOL

HasOptions() const

Do we have options
Protected function virtual void

InitializeIP()

initialize all the private memebers
Private function static sockaddr_in

InternalResolveDNS( const std::string& rAddress )

Reseolve DNS
Public function BOOL

IsCreated() const

Is this socket created ?
Protected function BOOL

IsRaw() const

Indication if we are a raw socket
Public function bool

operator <( const CSpoofSocket& rSocket ) const

Private function CSpoofSocket &

operator =( const CSpoofSocket& rSocket )

No assigment operator
Public function bool

operator ==( const CSpoofSocket& rSocket ) const

Operators, for compare
Public function virtual int

Receive( char* pBuffer, unsigned long ulBufferLength )

Recieve data from remote socket, can be used with all sub sockets (protocols) Return value: Positive - The number of bytes received.
Protected function virtual int

ReceiveFrom( char* pBuffer, unsigned long ulBufferLength, IP& rIP, unsigned short& rSourcePort )

Recieve data from remote socket, saving the address
Public function static long

ResolveDNS( const std::string& rAddress )

Resolve a DNS entry (using winsock2 routines)
Public function virtual int

Send( IP aDestinationAddress, const char* pBuffer, unsigned long ulBufferLength, unsigned short usDestinationPort=0 )

Send data to a socket , can be used with all sub sockets (protocols) Return value: Positive - The number of bytes received.
Public function virtual int

Send( const std::string& rDestinationAddress, const char* pBuffer, unsigned long ulBufferLength, unsigned short usDestinationPort=0 )

Public function virtual int

SendRawBuffer( IP aDestinationAddress, const char* pBuffer, unsigned long ulBufferLength, unsigned short usDestinationPort )

Send raw data Return value: Positive - The number of bytes sent.
Public function BOOL

SetBroadcast( BOOL bBroadcast )

Set to be a broadcast
Protected function void

SetConnectedTo( const sockaddr_in& rAddress )

Set the connected to
Protected function virtual void

SetIPHeaderAddress( LPIpHeader lpHead, IP aSourceAddress, IP aDestinationAddress ) const

Set the address in the IP header
Public function void

SetOptions( BOOL bOptions )

Do we allow options on this socket ?
Protected function void

SetProtocol( unsigned char ucProtocol )

Set the protocol we are working on
Public function BOOL

SetReceiveTimeout( unsigned long ulMS )

Set receive timeout (for blocked only)
Public function virtual void

SetSourceAddress( IP aSourceAddress )

Set source address for spoofing
Public function virtual void

SetSourceAddress( const std::string& rSourceAddress )

Public function void

SetTTL( unsigned char ucTTL )

Set the packet Time to live
Public function BOOL

Shutdown( SocketShutdown eHow )

Close one way of the socket (receive,send,both)
Public function virtual BOOL

Sniff( BOOL bSniff )

Turn to be a sniffer socket (only for raw sockets)
Public function static BOOL

ValidAddress( const std::string& rAddress )

Check if an address is valid
Protected function BOOL

ValidSocket() const

Is our socket valid ?

'Friends' icon -- Shortcut to top of page. Friends

class CIPCrafter

'Custom Code' icon -- Shortcut to top of page. Custom Code

'Implementation Details' icon -- Shortcut to top of page. Implementation Details

File(s)
C:\dev\Komodia\SpoofSocket.cpp
C:\dev\Komodia\SpoofSocket.h
Header Includes
SpoofBase.h     
Source Includes
stdafx.h     for precompiled header directive
SpoofSocket.h     
ErrorHandlerMacros.h     
Array_ptr.h     
memory     
Owner
tcpip4
Last Modified
20/02/2003 3:57:29 PM

Get Surveyor!This web site was generated using Surveyor V4.50.811.1.  Click here for more information. Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.