I need to right a VBS script that can have a text document passed to it, then it reads through the text document and looks for the last occurrence of Received From: ([127.0.0.1]) and adds a new line to the text file saying Originating-IP: 127.0.0.1
The command to run the VBS would need to be "extractIP.vbs 123454343454.txt" ie the text file to check through is specified. An example text from the file is the following.
Received: from mailfilteruk.com ([192.133.7.42]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:11:08 +0100
Received: from modernwebsites.myvirtuozzo.com ([192.133.7.32]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:09:58 +0100
Received: from modernwebsites.co.uk ([64.151.225.132] helo=modernwebsites.myvirtuozzo.com)
by MFS032F.mailfilteruk.com with ESMTP (2.0.1); 19 May 2011 16:06:05 +0100
Received: from host86-163-57-254.range86-163.btcentralplus.com ([86.163.57.254] helo=damien-intel.home)
by modernwebsites.myvirtuozzo.com with esmtpsa (TLSv1:AES256-SHA:256)
X-Originating-IP:86.163.57.254
As you can see there are several received from IP address, the one i need however is the last one in bold. To further complicate the issue the IP will be different each time so it will need to look for the last instance of received from: ([
It will then add the following string. X-Originating-IP:86.163.57.254 to the line after the received from line.
So it would then look like the following.
Received: from mailfilteruk.com ([192.133.7.42]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:11:08 +0100
Received: from modernwebsites.myvirtuozzo.com ([192.133.7.32]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:09:58 +0100
Received: from modernwebsites.co.uk ([64.151.225.132] helo=modernwebsites.myvirtuozzo.com)
by MFS032F.mailfilteruk.com with ESMTP (2.0.1); 19 May 2011 16:06:05 +0100
Received: from host86-163-57-254.range86-163.btcentralplus.com ([86.163.57.254] helo=damien-intel.home)
by modernwebsites.myvirtuozzo.com with esmtpsa (TLSv1:AES256-SHA:256)
X-Originating-IP:86.163.57.254
I hope that all makes sense.
ASKER