Urgent.News

What's breaking now, across thousands of outlets.

Tech

Simple TCP Client in Python

This is a guide to write a quick simple TCP client in pure python. First of all, why would anyone need this ? Industry Servers dosent have tools like curl or wget, and most of the time have restricted network access, so downloading using the package manager isn't possible too. But most if not all of the time, you can find a version of python installed. So we will try to make a TCP client without…

This article provides instructions for creating a basic TCP client using Python's built-in socket library. The need for this simple TCP client arises from the fact that many industry servers lack tools like curl or wget, and network access is often restricted, making package management downloads impossible. However, Python is almost always available, so we aim to build a TCP client without any additional libraries.

To begin, we import the socket module and define the target host (www.google.com) and target port (80). We then create a socket object with the AF_INET and SOCK_STREAM parameters. AF_INET represents a standard IPv4 address or hostname, while SOCK_STREAM indicates that this connection will be a TCP client. Following this, we establish a connection with the server and send some data to it.

The final step involves receiving the server's response and printing it out. This represents the simplest form of a TCP client, although it is a common task in programming. However, there are some assumptions made in this example that should be noted. Firstly, we assume that the connection will always be successful, and secondly, we assume that the server is always prepared to receive data from us. Our third assumption is that the server will respond to our requests promptly.

These assumptions are made primarily for simplicity's sake. While there is debate among programmers about how to handle blocking sockets, exception-handling in sockets, and similar issues, it is uncommon for pentesters to incorporate such niceties into quick-and-dirty tools used for reconnaissance or exploitation work. As such, these considerations are omitted in this guide.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Digital sovereignty

It is hardly surprising that the DICT is struggling to get foreign-based social media platforms to comply with local regulations.

"From Localhost to Live URL: The Zero-Friction Guide to Vercel and Custom Domains"

Taking a web project from your local machine to a live public URL can feel surprisingly overwhelming when you encounter GitHub pipelines, DNS records, nameservers, and SSL provisioning all at once.

  • Vercel simplifies website deployment from local to live URL with 4-step pipeline
  • Set up Git repository, link to GitHub, push to main branch for continuous deployment
  • Use custom domain by adding DNS records to domain registrar and pointing nameservers to Vercel

More from Thursday 1 October →