Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SendEmail
- {
- using System;
- using System.IO;
- public static class Program
- {
- public static void Main()
- {
- string neededUser = "suAdmin";
- string neededPasswor = "aDmInPw17";
- Console.WriteLine("Content-Type: text/html\r\n");
- string request = Environment.GetEnvironmentVariable("REQUEST_METHOD").ToLower();
- Console.WriteLine("<!DOCTYPE html>\r\n<html>\r\n<head>\r\n\t<title>Document</title>\r\n</head>\r\n<body>");
- if (request == "get")
- {
- PrintGetForm();
- }
- else if (request == "post")
- {
- string[] postData = Console.ReadLine().Split('&');
- string givenUsername = postData[0].Split('=')[1];
- string givenPassword = postData[1].Split('=')[1];
- if (givenUsername == neededUser & givenPassword == neededPasswor)
- {
- PrintPostForm();
- }
- else
- {
- PrintGetForm();
- Console.WriteLine("<p style=\"color: red;\">Invalid username or pass!</p>");
- }
- }
- Console.WriteLine("</body>\r\n</html>");
- }
- static void PrintGetForm()
- {
- Console.WriteLine("<h2>Login: </h2>\r\n\t<form action=\"SendEmail.exe\" method=\"POST\">\r\n\t\t<label for=\"username\">Username: </label>\r\n\t\t<input type=\"text\" name=\"username\" id=\"username\">\r\n\t\t<label for=\"password\">Password: </label>\r\n\t\t<input type=\"password\" name=\"password\">\r\n\t\t<input type=\"submit\" name=\"submit\" value=\"Login\">\r\n\t</form>");
- }
- static void PrintPostForm()
- {
- Console.WriteLine("<h2>Hello suAdmin</h2>\r\n\t<form action=\"\" method=\"POST\">\r\n\t\t<label for=\"to\">To: </label>\r\n\t\t<input type=\"text\" name=\"to\" id=\"to\">\r\n\t\t<label for=\"subject\">Subject: </label>\r\n\t\t<input type=\"text\" name=\"subject\" id=\"subject\">\r\n\t\t<label for=\"message\">Message: </label>\r\n\t\t<textarea id=\"message\"></textarea>\r\n\t\t<input type=\"submit\" name=\"send\" value=\"Send\">\r\n\t</form>");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement