Reply To: HTTP Redirection

Home Forums Discussions Support Portal HTTP Redirection Reply To: HTTP Redirection

#6107

Jaze
Participant

I have recalculated TCP checksum also. When sending packet I change desination IP and when recieving I change source IP(as was described in some topic here). Redirection of telnet, ping works fine and http redirection is not(( here is code


void filter()
{
WaitForSingleObject ( hEvent, INFINITE );
ResetEvent(hEvent);
while (api->ReadPacket(request))
{

if (buffer->m_dwDeviceFlags == PACKET_FLAG_ON_SEND)
{
printf("Attemp to send...n");
parsePacketHeaders(buffer);
api->SendPacketToAdapter(request);
}
if (buffer->m_dwDeviceFlags == PACKET_FLAG_ON_RECEIVE)
{
printf("Recieved...n");
parsePacketHeaders(buffer);
api->SendPacketToMstcp(request);
}

}

}

PINTERMEDIATE_BUFFER parsePacketHeaders ( PINTERMEDIATE_BUFFER pBuffer )
{
ether_header_ptr pEthernet = (ether_header_ptr)&pBuffer->m_IBuffer;

if(ntohs(pEthernet->h_proto) == ETH_P_IP)
{
iphdr_ptr pIp = NULL;
tcphdr_ptr pTcp = NULL;
pIp = (iphdr_ptr)&pBuffer->m_IBuffer[sizeof(ether_header)];
UCHAR IpProto = pIp->ip_p;

if(IpProto == IPPROTO_TCP)
{
//pTcp = (tcphdr_ptr)(((PUCHAR)pIp) + sizeof(DWORD)*pIp->ip_hl);
}//tcp??

//redirection here
if ((pIp->ip_dst.S_un.S_un_b.s_b3 == 32) & (pIp->ip_dst.S_un.S_un_b.s_b4 == 14))
{
pIp->ip_dst.S_un.S_un_b.s_b4 = 9;
pIp->ip_dst.S_un.S_un_b.s_b3 = 32;
recalculateIPChecksum(pBuffer);
recalculateTCPChecksum(pBuffer);
}
if ((pIp->ip_src.S_un.S_un_b.s_b3 == 32) & (pIp->ip_src.S_un.S_un_b.s_b4 == 9))
{
pIp->ip_src.S_un.S_un_b.s_b4 = 14;
pIp->ip_src.S_un.S_un_b.s_b3 = 32;
recalculateIPChecksum(pBuffer);
recalculateTCPChecksum(pBuffer);
}
}


return pBuffer;

}

SerpentFly – ты русский? Если да – то пиши по-русски)) А то я думал тут все из-за бугра.
Еще ethreal ом посмотрел – модифицированные http пакеты не выходят(( просто Ip(ping) telnet – нормально.