Welcome to Dream.In.Code
Become a VB Expert!

Join 137,261 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,559 people online right now. Registration is fast and FREE... Join Now!




String Comparison/Manipulation

 
Reply to this topicStart new topic

String Comparison/Manipulation

Emmanuel
20 Dec, 2006 - 10:50 AM
Post #1

New D.I.C Head
*

Joined: 20 Dec, 2006
Posts: 2


My Contributions
Hi

Im doing this sch proj can u all help on dis i alr cracking my head for so long on dis but im not able to solve it as i didnt get wad i want......i appreacite ure kind help...thanks

My proj is like dis

I need to create a tool which can detect spoofed email..

i need to compare two field from the email header tat is:

Received: from emmanuel.sp.edu ([202.21.157.40]) by student-mail.sp.edu with Microsoft SMTPSVC(6.0.3790.1830);"
Message-ID: <489958FF1A028542AC33B4CCD58A7DFDB102AB@emmanuel.sp.edu>

i need to compare particulary dis two field and specifically the email address in both fied such as if both the email add in both field are same den is Genuine email else its Fake..

my codes tat i did is

CODE

Dim r As String = "Message-ID: <489958FF1A028542AC33B4CCD58A7DFDB102AB@emmanuel.sp.edu>"
Dim a As String = "Received: from emmanuel.sp.edu([202.21.157.40]) by student-mail.sp.edu with Microsoft SMTPSVC(6.0.3790.1830);"


        If ProgressBar1.Value <= ProgressBar1.Maximum - 1 Then
            ProgressBar1.Value += 20
            Label2.Visible = False
        Else
            Timer1.Enabled = False
            ProgressBar1.Value = 0
            Label2.Visible = True

            Label2.Text = "Trace Completed"

            a = a.Substring(14, 22)
            r = r.Substring(52, 20)
            If String.Compare(a, r) = True Then
                MsgBox("Genuine Email")
            End If
            If String.Compare(a, r) = False Then
                MsgBox("Spoofed Email")
            End If

i want to compare both field with emmanuel.sp.edu from the messege-ID and Received from field that i input in textbox1 den once i click on the button(trace) the it will carried out the scan.

Hope u all can help me on dis

thank u so much....

EDIT : Added code tags -b2c-
User is offlineProfile CardPM
+Quote Post

Dustyd63
RE: String Comparison/Manipulation
23 Dec, 2006 - 07:01 AM
Post #2

New D.I.C Head
*

Joined: 21 Aug, 2006
Posts: 4


My Contributions
Shouldn't be too bad... Notice how I use the static characters of the string to get the server names - makes the code a little more dynamic than yours.

Dim i As Integer
Dim j As Integer
Dim server1 As String
Dim server2 As String

Dim r As String
r = "Message-ID: <489958FF1A028542AC33B4CCD58A7DFDB102AB@emmanuel.sp.edu>"
Dim a As String
a = "Received: from emmanuel.sp.edu([202.21.157.40]) by student-mail.sp.edu with Microsoft SMTPSVC(6.0.3790.1830);"

i = InStr("@", r)
j = InStr(">", r)

server1 = TextBox1.Text = a.Substring(i, j)

i = InStr("([", a)
server2 = a.Substring(15, i)

If String.Compare(TextBox1.Text, server1) = 0 And String.Compare(TextBox1.Text, server2) = 0 Then
MsgBox("Genuine Email")
Else
MsgBox("Spoofed Email")
End If

Note that this code isn't tested... I would have, but for some reason Windows thought it fit to unregister Microsoft's debugger dll and refuse to re-register it. I probably made some dumb mistake in there, so if it doesn't work, step through it. I'm probably off by a number between the Instr and Substring.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 06:50PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month