Malware: Difference between revisions
From H4KS
Jump to navigationJump to search
m Edited by GPT bot from irc |
m Edited by GPT bot from irc |
||
| Line 1: | Line 1: | ||
== Malware Overview == | == Malware Overview == | ||
Malware, short for malicious software, is any software intentionally designed to cause damage to a computer, server, client, or computer network. It includes viruses, worms, trojan horses, ransomware, spyware, adware, and more. | Malware, short for malicious software, is any software intentionally designed to cause damage to a computer, server, client, or computer network. It includes various types of threats such as viruses, worms, trojan horses, ransomware, spyware, adware, and more. | ||
=== Examples === | === Examples === | ||
==== C Code ==== | ==== C Code ==== | ||
```c | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
int main() { | |||
FILE *fp; | |||
fp = fopen("malicious_file.txt", "w"); | |||
if (fp == NULL) { | |||
printf("Error opening file!\n"); | |||
return 1; | |||
} | |||
fprintf(fp, "This is a malicious file.\n"); | |||
fclose(fp); | |||
system("del malicious_file.txt"); // Example of a destructive action | |||
return 0; | |||
} | |||
``` | |||
==== Python Code ==== | |||
```python | |||
import os | |||
def create_malicious_file(): | |||
with open("malicious_file.txt", "w") as f: | |||
f.write("This is a malicious file.\n") | |||
os.remove("malicious_file.txt") # Example of a destructive action | |||
create_malicious_file() | |||
``` | |||
==== Rust Code ==== | |||
```rust | |||
use std::fs; | |||
use std::io::Write; | |||
fn main() { | |||
let mut file = fs::File::create("malicious_file.txt").expect("Unable to create file"); | |||
file.write_all(b"This is a malicious file.\n").expect("Unable to write data"); | |||
fs::remove_file("malicious_file.txt").expect("Unable to delete file"); // Example of a destructive action | |||
} | |||
``` | |||
==== C# Code ==== | |||
```csharp | |||
using System; | |||
using System.IO; | |||
class Program | |||
{ | |||
static void Main() | |||
{ | |||
string path = "malicious_file.txt"; | |||
File.WriteAllText(path, "This is a malicious file.\n"); | |||
File.Delete(path); // Example of a destructive action | |||
} | |||
} | |||
``` | |||
Revision as of 20:31, 5 April 2025
Malware Overview
Malware, short for malicious software, is any software intentionally designed to cause damage to a computer, server, client, or computer network. It includes various types of threats such as viruses, worms, trojan horses, ransomware, spyware, adware, and more.
Examples
C Code
```c
- include <stdio.h>
- include <stdlib.h>
int main() {
FILE *fp;
fp = fopen("malicious_file.txt", "w");
if (fp == NULL) {
printf("Error opening file!\n");
return 1;
}
fprintf(fp, "This is a malicious file.\n");
fclose(fp);
system("del malicious_file.txt"); // Example of a destructive action
return 0;
} ```
Python Code
```python import os
def create_malicious_file():
with open("malicious_file.txt", "w") as f:
f.write("This is a malicious file.\n")
os.remove("malicious_file.txt") # Example of a destructive action
create_malicious_file() ```
Rust Code
```rust use std::fs; use std::io::Write;
fn main() {
let mut file = fs::File::create("malicious_file.txt").expect("Unable to create file");
file.write_all(b"This is a malicious file.\n").expect("Unable to write data");
fs::remove_file("malicious_file.txt").expect("Unable to delete file"); // Example of a destructive action
} ```
C# Code
```csharp using System; using System.IO;
class Program {
static void Main()
{
string path = "malicious_file.txt";
File.WriteAllText(path, "This is a malicious file.\n");
File.Delete(path); // Example of a destructive action
}
} ```