Skip to content

Instantly share code, notes, and snippets.

@quangnle
Created May 10, 2016 10:38
Show Gist options
  • Save quangnle/00240591de9700dd54829eb617c938a2 to your computer and use it in GitHub Desktop.
Save quangnle/00240591de9700dd54829eb617c938a2 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Tuenti16
{
class Program
{
static void Main(string[] args)
{
TcpClient server;
try
{
server = new TcpClient("52.49.91.111", 9999);
}
catch (SocketException)
{
Console.WriteLine("Unable to connect to server");
return;
}
var buffer = new byte[1024];
NetworkStream ns = server.GetStream();
int recv = ns.Read(buffer, 0, buffer.Length);
var stringData = Encoding.ASCII.GetString(buffer, 0, recv);
Console.WriteLine(stringData);
var data = new byte[0x40];
var len = 8;
var st = "DECODING";
for (int i = 0; i < len; i++)
{
data[i] = (byte)st[i];
data[0x10 + i] = (byte)st[i];
}
data[data.Length - 4] = 1;
while (true)
{
ns.Write(data, 0, data.Length);
ns.Flush();
buffer = new byte[1024];
recv = ns.Read(buffer, 0, buffer.Length);
stringData = Encoding.ASCII.GetString(buffer, 0, recv);
Console.WriteLine(stringData);
if (stringData.Length > 0) break;
}
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment