r6
| 1 | [[분류:Aidenk]] |
|---|
| 2 | [목차] |
|---|
r1
| 3 | == 개요 == |
|---|
| 4 | 특정 서버나 네트워크에 과도한 트래픽을 발생시켜 정상적인 서비스 제공을 방해하는 사이버 공격. |
|---|
| 5 | |
|---|
r2
| 6 | 매우 간단한 예제이다. |
|---|
r12
| 7 | 원리는 requests로 서버에 과부화를 주는 것. --사실상 이코드로 DDos 공격은 불가능이다. 애초에 구글 도메인에 get을 해야하기에...-- |
|---|
r1
| 8 | |
|---|
r8
| 9 | 신기하게 깃허브에는 DDOS 코드가 존재한다... |
|---|
| 10 | |
|---|
r14
| 11 | * python |
|---|
r1
| 12 | {{{#!syntax python |
|---|
| 13 | import requests |
|---|
| 14 | |
|---|
r4
| 15 | url = "https://www.google.com" |
|---|
r1
| 16 | |
|---|
| 17 | for i in range(1): |
|---|
r9
| 18 | a = requests.post(url) |
|---|
r5
| 19 | |
|---|
| 20 | print(a) |
|---|
| 21 | print(a.text) |
|---|
r6
| 22 | }}} |
|---|
| 23 | |
|---|
r14
| 24 | * c# |
|---|
r10
| 25 | {{{#!syntax csharp |
|---|
| 26 | using System; |
|---|
| 27 | using System.Net.Http; |
|---|
| 28 | using System.Threading.Tasks; |
|---|
| 29 | |
|---|
| 30 | class Program |
|---|
| 31 | { |
|---|
| 32 | static async Task Main(string[] args) |
|---|
| 33 | { |
|---|
| 34 | string url = "https://www.google.com"; |
|---|
| 35 | |
|---|
| 36 | using (HttpClient client = new HttpClient()) |
|---|
| 37 | { |
|---|
| 38 | HttpResponseMessage response = await client.PostAsync(url, null); |
|---|
| 39 | |
|---|
| 40 | Console.WriteLine(response); |
|---|
| 41 | string text = await response.Content.ReadAsStringAsync(); |
|---|
| 42 | Console.WriteLine(text); |
|---|
| 43 | } |
|---|
| 44 | } |
|---|
| 45 | } }}} |
|---|
r14
| 46 | |
|---|
| 47 | * cpp |
|---|
r10
| 48 | {{{#!syntax cpp |
|---|
r11
| 49 | #include <iostream> |
|---|
| 50 | #include <string> |
|---|
| 51 | #include <curl/curl.h> |
|---|
r10
| 52 | |
|---|
r11
| 53 | size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* buffer) { |
|---|
| 54 | size_t totalSize = size * nmemb; |
|---|
| 55 | buffer->append((char*)contents, totalSize); |
|---|
| 56 | return totalSize; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | int main() { |
|---|
| 60 | CURL* curl; |
|---|
| 61 | CURLcode res; |
|---|
| 62 | std::string response; |
|---|
| 63 | |
|---|
| 64 | curl = curl_easy_init(); |
|---|
| 65 | |
|---|
| 66 | if (curl) { |
|---|
| 67 | curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com"); |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | curl_easy_setopt(curl, CURLOPT_POST, 1L); |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); |
|---|
| 74 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | res = curl_easy_perform(curl); |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | std::cout << "Response Code: " << res << std::endl; |
|---|
| 81 | std::cout << "Response Text:\n" << response << std::endl; |
|---|
| 82 | |
|---|
| 83 | curl_easy_cleanup(curl); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | return 0; |
|---|
| 87 | } |
|---|
r10
| 88 | }}} |
|---|
| 89 | |
|---|
r14
| 90 | * ruby |
|---|
r13
| 91 | {{{#!syntax ruby |
|---|
| 92 | require 'net/http' |
|---|
| 93 | require 'uri' |
|---|
| 94 | |
|---|
| 95 | url = URI.parse("https://www.google.com") |
|---|
| 96 | |
|---|
| 97 | http = Net::HTTP.new(url.host, url.port) |
|---|
| 98 | http.use_ssl = true |
|---|
| 99 | |
|---|
| 100 | request = Net::HTTP::Post.new(url.request_uri) |
|---|
| 101 | |
|---|
| 102 | response = http.request(request) |
|---|
| 103 | |
|---|
| 104 | puts response |
|---|
| 105 | puts response.body |
|---|
| 106 | }}} |
|---|
r14
| 107 | |
|---|
| 108 | * java |
|---|
| 109 | {{{#!syntax java |
|---|
| 110 | import java.net.URI; |
|---|
| 111 | import java.net.http.HttpClient; |
|---|
| 112 | import java.net.http.HttpRequest; |
|---|
| 113 | import java.net.http.HttpResponse; |
|---|
| 114 | |
|---|
| 115 | public class Main { |
|---|
| 116 | public static void main(String[] args) throws Exception { |
|---|
| 117 | String url = "https://www.google.com"; |
|---|
| 118 | |
|---|
| 119 | HttpClient client = HttpClient.newHttpClient(); |
|---|
| 120 | |
|---|
| 121 | HttpRequest request = HttpRequest.newBuilder() |
|---|
| 122 | .uri(URI.create(url)) |
|---|
| 123 | .POST(HttpRequest.BodyPublishers.noBody()) |
|---|
| 124 | .build(); |
|---|
| 125 | |
|---|
| 126 | HttpResponse<String> response = |
|---|
| 127 | client.send(request, HttpResponse.BodyHandlers.ofString()); |
|---|
| 128 | |
|---|
| 129 | System.out.println(response); |
|---|
| 130 | System.out.println(response.body()); |
|---|
| 131 | } |
|---|
| 132 | } |
|---|
| 133 | }}} |
|---|
r6
| 134 | == 범죄 == |
|---|
| 135 | 사이버 공격은 엄연한 범죄이다. |
|---|