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