Advertisement
RieqyNS13

Untitled

Jul 7th, 2015
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.00 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Text.RegularExpressions;
  4. using System.IO;
  5. using System.Net;
  6. using System.Net.Sockets;
  7. using System.Threading;
  8. using System.Windows.Forms;
  9. class injek {
  10.     const string server_ip = "10.19.19.19";
  11.     //const string server_ip = "49.213.22.154"; //dari a.buzzmechat.com
  12.     const int server_port = 8080;
  13.     public static Socket GayClient = null; //dari TcpListener
  14.     public static Socket GayServer = null; //
  15.     static string _replace(string text) {
  16.         string[] pola = new string[] { "HTTP/1.1 402 Forbidden", "HTTP/1.1 403 Forbidden",
  17.             "HTTP/1.0 402 Bad Request", "HTTP/1.1 402 Bad Request", "HTTP/1.0 403 Bad request", "HTTP/1.1 400 Bad Request",
  18.             "HTTP/1.0 502 Gateway Timeout", "HTTP/1.1 502 Internal Server Error", "HTTP/1.1 402 not authenticated", "HTTP/1.1 100 Connection established"
  19.         };
  20.  
  21.         foreach (string cok in pola)
  22.         {
  23.             text = Regex.Replace(text, cok, "HTTP/1.1 200 OK");
  24.         }
  25.  
  26.         return text;
  27.     }
  28.  
  29.     public static void konekServer(string rawurl) {
  30.         Socket Gay = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  31.         try {
  32.             //string request = "GET http://a.buzzmechat.com/ HTTP/1.1\r\nHost: a.buzzmechat.com" +"\r\nConnection: keep-alive"+
  33.             //"\r\n\r\n\r\n"+"CONNECT " + rawurl + " HTTP/1.0\r\n";'
  34.             string netdata = "CONNECT " + rawurl + " HTTP/1.0\r\n\r\n";
  35.             netdata+= "GET http://z022.fma.fb.me HTTP/1.1\r\n\r\n";
  36.             netdata+= "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0 Host : z022.fma.fb.me\r\n\r\n";
  37.             netdata+= "CONNECT " + rawurl + " HTTP/1.0\r\n\r\n";
  38.             netdata+= "GET http://z022.fma.fb.me HTTP/1.1\r\n\r\n";
  39.             netdata+= "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0 Host : z022.fma.fb.me\r\n\r\n\r\n";
  40.  
  41.             //netdata+= "Connection: Keep-Alive\r\nHost: m.skype.com\r\nX-Online-Host: m.skype.com\r\n\r\n";
  42.  
  43.             //Byte[] bytesSent = Encoding.ASCII.GetBytes(request);
  44.             Byte[] bytesSent = Encoding.ASCII.GetBytes(netdata);
  45.             Byte[] bytesReceived = new Byte[1028];
  46.             Gay.Connect(new IPEndPoint(IPAddress.Parse(server_ip), server_port));
  47.             if(Gay.Connected) {
  48.                 Console.WriteLine("Konek sukses");
  49.                 Gay.Send(bytesSent);
  50.             }else {
  51.                 Console.WriteLine("Gak Konek");
  52.                 GayClient.Shutdown(SocketShutdown.Both);
  53.                 GayClient.Close();
  54.             }
  55.  
  56.             GayServer = Gay;
  57.             homo();
  58.         }
  59.         catch(Exception e) {
  60.             Console.WriteLine(e.ToString());
  61.         }
  62.     }
  63.  
  64.     public static void cek(Socket sk) {
  65.         GayClient = sk;
  66.         Byte[] recv = new Byte[1028];
  67.         int len;
  68.         len = sk.Receive(recv);
  69.         string clientmsg = Encoding.ASCII.GetString(recv);
  70.         string cmd = clientmsg.Split(' ')[0].Trim();
  71.         string rawurl = clientmsg.Split(' ')[1].Trim();
  72.         Console.WriteLine("Data dari client : < "+len+" > "+clientmsg);
  73.         if(cmd == "CONNECT") {
  74.             Console.WriteLine("Konek server : < "+len+" > "+clientmsg);
  75.            
  76.             konekServer(rawurl);
  77.             //homo();
  78.         }
  79.         else {
  80.             MessageBox.Show("Jembot");
  81.             Console.WriteLine("Mbuh : < "+len+" > "+clientmsg);
  82.             konekServer(rawurl);
  83.             //gay2();
  84.         }
  85.     }
  86.  
  87.     public static void homo() {
  88.         while(true) {
  89.             try {
  90.                 string page = null;
  91.                 Byte[] recv = new Byte[1028];
  92.                 Byte[] send = new Byte[1028];
  93.                 //int len = GayServer.Receive(recv);
  94.                 int len = GayServer.Receive(recv, recv.Length, SocketFlags.None);
  95.                 if(len == 0) {
  96.                     MessageBox.Show("break cok", "GayServer");
  97.                     Console.WriteLine("\r\nData dari server : <"+len+"> "+ Encoding.ASCII.GetString(recv));
  98.                     //break;
  99.                 }else {
  100.                     page = Encoding.ASCII.GetString(recv);
  101.                     page = _replace(page);
  102.                     send = Encoding.ASCII.GetBytes(page);
  103.                     Console.WriteLine("\r\nData dari server : <"+len+"> "+ page);
  104.                     MessageBox.Show(page, "From Server");
  105.                     GayClient.Send(send, len, SocketFlags.None);
  106.                 }
  107.  
  108.                 len = GayClient.Receive(recv, recv.Length, SocketFlags.None);
  109.                 if(len == 0) {
  110.                     MessageBox.Show("break jancok", "GayClient");
  111.                     //break;
  112.                 }else {
  113.                     page = Encoding.ASCII.GetString(recv);
  114.                     page = _replace(page);
  115.                     Console.WriteLine("\r\nData dari client : <"+len+"> "+page);
  116.                     MessageBox.Show(page, "From Client");
  117.                     send = Encoding.ASCII.GetBytes(page);
  118.                     GayServer.Send(send, len, SocketFlags.None);
  119.                 }
  120.             }
  121.             catch(Exception e) {
  122.                 MessageBox.Show(e.ToString());
  123.             }
  124.         }
  125.  
  126.         try
  127.         {
  128.             GayServer.Shutdown(SocketShutdown.Both);
  129.             GayClient.Shutdown(SocketShutdown.Both);
  130.             GayServer.Close();
  131.             GayClient.Close();
  132.         }
  133.         catch(Exception e) {
  134.             Console.WriteLine(e.ToString());
  135.         }
  136.     }
  137.  
  138.     public static void Main() {
  139.         try {
  140.             TcpListener listen = new TcpListener(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 668));
  141.             listen.Start();
  142.             Socket sk;
  143.             while(true) {
  144.                 try {
  145.                     Console.WriteLine("Ngenteni cok..");
  146.                     sk = listen.AcceptSocket();
  147.                     cek(sk);
  148.                     //new Thread(() => {
  149.                        
  150.                     //}).Start();
  151.                 }
  152.                 catch(Exception e) {
  153.                     Console.WriteLine(e.ToString());
  154.                 }
  155.             }
  156.         }
  157.         catch(Exception e) {
  158.             Console.WriteLine(e.ToString());
  159.         }
  160.        
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement