Skip to content

Instantly share code, notes, and snippets.

View fffaraz's full-sized avatar
🚀
Focusing

Faraz Fallahi fffaraz

🚀
Focusing
View GitHub Profile
@fffaraz
fffaraz / rand.cpp
Created July 22, 2014 10:51
Random number in Qt
#include <QGlobal.h>
#include <QTime>
int QMyClass::randInt(int low, int high)
{
// Random number between low and high
return qrand() % ((high + 1) - low) + low;
}
// Create seed for the random
@fffaraz
fffaraz / dns.c
Created May 29, 2016 05:58
DNS Query Code in C with linux sockets
//DNS Query Program on Linux
//Author : Silver Moon (m00n.silv3r@gmail.com)
//Dated : 29/4/2009
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
@fffaraz
fffaraz / portscanner.c
Last active December 17, 2023 07:56
Port scanner code in c
#include "stdio.h"
#include "sys/socket.h"
#include "errno.h"
#include "netdb.h"
#include "string.h"
#include "stdlib.h"
int main(int argc , char **argv)
{
struct hostent *host;
@fffaraz
fffaraz / resources.md
Last active November 8, 2023 22:55
CS 306 - Linux/UNIX Programming
@fffaraz
fffaraz / tcp_syn.py
Created July 30, 2014 22:07
TCP syn flood in python using raw sockets
'''
Syn flood program in python using raw sockets (Linux)
http://www.binarytides.com/python-syn-flood-program-raw-sockets-linux/
Silver Moon (m00n.silv3r@gmail.com)
'''
# some imports
import socket, sys
from struct import *
@fffaraz
fffaraz / tcpKeepAlive.c
Created June 12, 2015 06:55
SO_KEEPALIVE
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int enableKeepAlive = 1;
int fd = tcpSocket->socketDescriptor();
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &enableKeepAlive, sizeof(enableKeepAlive));
int maxIdle = 300;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle));
@fffaraz
fffaraz / lsniffer.c
Last active February 12, 2023 11:42
Packet Sniffer Code in C using Linux Sockets | http://www.binarytides.com/packet-sniffer-code-c-linux/
/*
Packet sniffer using libpcap library
*/
#include<pcap.h>
#include<stdio.h>
#include<stdlib.h> // for exit()
#include<string.h> //for memset
#include<sys/socket.h>
#include<arpa/inet.h> // for inet_ntoa()
#include<stdio.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<features.h>
#include<linux/if_packet.h>
#include<linux/if_ether.h>
#include<errno.h>
#include<sys/ioctl.h>
#include<net/if.h>
#include<net/ethernet.h>
@fffaraz
fffaraz / tr4_ll.c
Created November 12, 2015 02:59
TCP/ICMP/UDP traceroute
/* Copyright (C) 2012-2015 P.D. Buchan (pdbuchan@yahoo.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the