GameOver
03-22-2013, 10:31 PM
Hey HF
today i will be teaching you how to make a more secure contact form for your vb.net applications. so lets begin. this is the obvious and most used contact form in vb.net
Imports System.Net.Mail
Public Class Help
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim smtpServer As New SmtpClient()
Dim mail As New MailMessage()
smtpServer.Credentials = New Net.NetworkCredential("[email protected]", "hackthishf")
'using gmail
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("[email protected]")
mail.To.Add("[email protected]")
mail.Subject = "Report!"
mail.Body = (TextBox2.Text + " -From" & TextBox1.Text)
smtpServer.Send(mail)
MsgBox("Sent!")
End Sub
End Class
however the problem with this as you can see is that all it takes is someone to decompile your program and BAM! they have access to your gmail account! so we will be using a PHP script and the web request to send our mail!
so for this you will need a webhoster but you can easily get free hosting from :
SpinHost.net - Cheap Web hosting (http://www.spinhost.net/)
so create a new PHP document and paste this code :
<?php
// subject
$subject="Error / Bug Report";
// Details
$message= addslashes($_GET['msg']);
// Mail of sender this can be anything.
$mail_from="[email protected]";
// From
$header="from: $name <$mail_from>";
// Enter your email address
$to ='[email protected]';
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display sent message
if($send_contact){
echo "Sent Successfully!";
}
else {
// Uh OHH! Display Error!
echo "Error - Could Not Send, Please Wait 5-10 Mins And Try Again!";
}
?>
then save it as mailer.php
so now go to your vb.net application and set up a new form and add the following :
http://gyazo.com/aa92152a85d5cbf29c95c8887cd040c2.png?1363989559
Now Double Click button one and paste this code :
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.yoursite.com/mailer.php?msg=" & textbox1.text)
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream( ))
Dim sauce As String = sr.ReadToEnd
MsgBox(sauce)
now we can add some validation if preferred, so before the above code write the following :
If TextBox1.Text.Length < 30 Then
MsgBox("Please Enter A Message!")
Else
then add End If below the rest of the code. so now it validates that the message entered is above 30 charecters to avoid spam. so lets see some testing :
10 characters :
http://gyazo.com/8b76e3556e9b19dc92c6e792e043c913.png?1363990315
Email Test
http://gyazo.com/5135a45400c271f36b35b8090b6ee517.png?1363991211
and upon checking our email :
http://gyazo.com/3b89a1455885a4f032f7ee560fc6d0d0.png?1363991246
hope you enjoyed
-Rape Face
today i will be teaching you how to make a more secure contact form for your vb.net applications. so lets begin. this is the obvious and most used contact form in vb.net
Imports System.Net.Mail
Public Class Help
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim smtpServer As New SmtpClient()
Dim mail As New MailMessage()
smtpServer.Credentials = New Net.NetworkCredential("[email protected]", "hackthishf")
'using gmail
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("[email protected]")
mail.To.Add("[email protected]")
mail.Subject = "Report!"
mail.Body = (TextBox2.Text + " -From" & TextBox1.Text)
smtpServer.Send(mail)
MsgBox("Sent!")
End Sub
End Class
however the problem with this as you can see is that all it takes is someone to decompile your program and BAM! they have access to your gmail account! so we will be using a PHP script and the web request to send our mail!
so for this you will need a webhoster but you can easily get free hosting from :
SpinHost.net - Cheap Web hosting (http://www.spinhost.net/)
so create a new PHP document and paste this code :
<?php
// subject
$subject="Error / Bug Report";
// Details
$message= addslashes($_GET['msg']);
// Mail of sender this can be anything.
$mail_from="[email protected]";
// From
$header="from: $name <$mail_from>";
// Enter your email address
$to ='[email protected]';
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display sent message
if($send_contact){
echo "Sent Successfully!";
}
else {
// Uh OHH! Display Error!
echo "Error - Could Not Send, Please Wait 5-10 Mins And Try Again!";
}
?>
then save it as mailer.php
so now go to your vb.net application and set up a new form and add the following :
http://gyazo.com/aa92152a85d5cbf29c95c8887cd040c2.png?1363989559
Now Double Click button one and paste this code :
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.yoursite.com/mailer.php?msg=" & textbox1.text)
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream( ))
Dim sauce As String = sr.ReadToEnd
MsgBox(sauce)
now we can add some validation if preferred, so before the above code write the following :
If TextBox1.Text.Length < 30 Then
MsgBox("Please Enter A Message!")
Else
then add End If below the rest of the code. so now it validates that the message entered is above 30 charecters to avoid spam. so lets see some testing :
10 characters :
http://gyazo.com/8b76e3556e9b19dc92c6e792e043c913.png?1363990315
Email Test
http://gyazo.com/5135a45400c271f36b35b8090b6ee517.png?1363991211
and upon checking our email :
http://gyazo.com/3b89a1455885a4f032f7ee560fc6d0d0.png?1363991246
hope you enjoyed
-Rape Face