Search the Community
Showing results for tags 'csharp'.
-
BRIEF CONTENTS Foreword by Matt Graeber Preface Chapter 1: C# Crash Course Chapter 2: Fuzzing and Exploiting XSS and SQLInjection Chapter 3: Fuzzing SOAP Endpoints Chapter 4: Writing Connect-Back, Binding, and Metasploit Payloads Chapter 5: Automating Nessus Chapter 6: Automating Nexpose Chapter 7: Automating OpenVAS Chapter 8: Automating Cuckoo Sandbox Chapter 9: Automating sqlmap Chapter 10: Automating ClamAV Chapter 11: Automating Metasploit Chapter 12: Automating Arachni Chapter 13: Decompiling and Reversing Managed Assemblies Chapter 14: Reading Offline Registry Hives https://www.google.ro/url?sa=t&source=web&rct=j&url=https://dl.kuroy.me/foreign/learnflakes/Brandon%20Perry%20-%20Gray%20Hat%20C%23/Brandon%20Perry%20-%20Gray%20Hat%20C%23_%20A%20Hacker%27s%20Guide%20to%20Creating%20and%20Automating%20Security%20Tools.pdf&ved=0ahUKEwjk_NfE74nYAhVS46QKHQNyCC4QFggjMAA&usg=AOvVaw1eTppV_6dAAZgoATyu8nOR https://smtebooks.com/Downloads/5794/gray-hat-c-pdf https://github.com/brandonprry/gray_hat_csharp_code https://books.google.ro/books?id=uAYvDwAAQBAJ&pg=PA130&lpg=PA130&dq=Gray+Hat+C%23:+Creating+and+Automating+Security+Tools+pdf&source=bl&ots=ZmCsAeFAsJ&sig=TmcTTAcgaYNH5c6nwy33VaY6fhQ&hl=ro&sa=X&ved=0ahUKEwiKnZr3w-bWAhXMKVAKHexJAA04ChDoAQgkMAE#v=onepage&q=Gray Hat C%23%3A Creating and Automating Security Tools pdf&f=false
-
I am trying to make a C# Chat. So far i have been able to work on getting the 2 clients to work together and send notification using the notifyicon. now What i want to achieve is something done by yahoo messenger. If i am online and dont have a messenger window on (if i am not talking to anyone) and someone sends me a message on LAN, I should be able to receive a new Message window. My code looks like this : using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net.Sockets; using System.Net; namespace ChatTestNowx { public partial class Form1 : Form { Socket sock; EndPoint epLocal, epRemote; byte[] buffer; public Form1() { InitializeComponent(); } private void groupBox2_Enter(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); pc1IP.Text = GetLocalIP(); Pc2IP.Text = GetLocalIP(); Message.KeyDown += new KeyEventHandler(MyKeyDownFunction); // Event to open new chat window on PC } //Message.KeyDown += new KeyEventHandler(MyKeyDownFunction); private void MyKeyDownFunction(object sender, KeyEventArgs e) { // Open new Chat window and show chat information } private void MessageCallBack(IAsyncResult aResult) { try { byte[] receivedData = new byte[1500]; receivedData = (byte[])aResult.AsyncState; ASCIIEncoding asc = new ASCIIEncoding(); string recievedMsg = asc.GetString(receivedData); listMessage.Items.Add("Friend:" + recievedMsg); buffer = new byte[1500]; sock.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void send_btn_Click(object sender, EventArgs e) { ASCIIEncoding aec = new ASCIIEncoding(); byte[] sendingMessage = new byte[1500]; sendingMessage = aec.GetBytes(Message.Text); sock.Send(sendingMessage); listMessage.Items.Add("Me :" + Message.Text); Message.Text = ""; } private string GetLocalIP() { IPHostEntry host; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { return ip.ToString(); } } return "127.0.0.1"; } private void Message_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //this.WindowState = FormWindowState.Normal; ASCIIEncoding aec = new ASCIIEncoding(); byte[] sendingMessage = new byte[1500]; sendingMessage = aec.GetBytes(Message.Text); sock.Send(sendingMessage); listMessage.Items.Add("Me :" + Message.Text); Message.Text = ""; } } private void connect_btn_Click(object sender, EventArgs e) { epLocal = new IPEndPoint(IPAddress.Parse(pc1IP.Text), Convert.ToInt32(pc1Port.Text)); sock.Bind(epLocal); epRemote = new IPEndPoint(IPAddress.Parse(Pc2IP.Text), Convert.ToInt32(Pc2Port.Text)); sock.Connect(epRemote); buffer = new byte[1500]; sock.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer); connect_btn.Text = "&Connected!"; connect_btn.Enabled = false; } } } What i have tried so far, I created events. And wanted to use this event only it does not work as i expected i added this and it does not work as i expected , hence i had to take it out. if (e.KeyCode == Keys.Enter) { Form1 frm = new Form1(); frm.Show(); ASCIIEncoding aec = new ASCIIEncoding(); byte[] sendingMessage = new byte[1500]; sendingMessage = aec.GetBytes(Message.Text); //sock.Send(sendingMessage); listMessage.Items.Add("Me :" + Message.Text); Message.Text = ""; }