Skip to content

Commit

Permalink
[2.0.0] Add modules and DLLs
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricelambert authored Mar 28, 2022
1 parent 2839949 commit 84921e7
Show file tree
Hide file tree
Showing 29 changed files with 1,375 additions and 0 deletions.
179 changes: 179 additions & 0 deletions DLL/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# EicarSpam

## How to use

### Python

```python
# Windows
from ctypes import windll as sysdll
filename = "EicarSpam.dll"

# Linux
from ctypes import cdll as sysdll
filename = "EicarSpam.so"

from os.path import abspath
eicarspam = sysdll.LoadLibrary(abspath("EicarSpam.dll"))
eicarspam.eicar(300)
```

### Ruby

```rb
# Windows
FILENAME = "EicarSpam.dll"

# Linux
FILENAME = "EicarSpam.so"

require 'fiddle/import'
require 'fiddle/types'

module EicarSpam
extend Fiddle::Importer
dlload File.join(Dir.pwd, FILENAME)
include Fiddle::Win32Types
extern 'int eicar(int)'
end

EicarSpam.eicar(5)
```

### Perl

```perl
# Windows
use Cwd qw(abs_path);
use File::Spec;
use Win32::API;

Win32::API->Import(abs_path(File::Spec->canonpath('EicarSpam.dll')),'int eicar(int x)');
eicar(5);
```

### JScript

```bash
# download dynwrapx.dll (https://dynwrapx.script-coding.com/dwx/pages/download.php?ver=2.2.0.0&lang=en)
regsvr32.exe /i <path>\dynwrapx.dll
cscript EicarSpam.js
```

```js
var oDynaWrap = new ActiveXObject( "DynamicWrapper" )
oDynaWrap.Register( "EicarSpam.dll", "eicar", "I=l", "R=l" ) // I(input)=l(int), R(return)=l(int)
oDynaWrap.eicar(5)
```

### VBScript

```bash
# download dynwrapx.dll (https://dynwrapx.script-coding.com/dwx/pages/download.php?ver=2.2.0.0&lang=en)
regsvr32.exe /i <path>\dynwrapx.dll
cscript EicarSpam.vbs
```

```vbs
Set DX = CreateObject("DynamicWrapperX")
DX.Register "EicarSpam.dll", "eicar", "i=l", "r=l"
DX.eicar(5)
```

## Sources

### Rust

```rs
use std::fs;

#[no_mangle]
pub extern fn eicar(x: i32) -> i32 {
let eicar = format!(
"{}EICAR-STANDARD-ANTIVIRUS-TEST-FILE{end}",
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$",
end="!$H+H*"
);

for x in 0..x {
fs::write(
format!("test{}.txt", x), eicar.clone()
);
}

return 0;
}
```

### C

```c
#include<stdio.h>

__declspec( dllexport ) int eicar(int x) {
FILE *file;
char filename[12];

for(int i = 0; i < x; i++) {
snprintf(filename, 12, "test%d.txt", i);
file = fopen(filename, "w");
if(file == NULL) {
printf("file can't be opened\n");
return 1;
}

fprintf(
file,
"%sEICAR-STANDARD-ANTIVIRUS-TEST-FILE%s",
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$",
"!$H+H*"
);
}

fclose(file);

return 0;
}
```
### Go
```go
package main
import (
"log"
"os"
"fmt"
"C"
)
//export eicar
func eicar(x C.uint) C.uint {
var datas [3]string
datas[0] = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$"
datas[1] = "EICAR-STANDARD-ANTIVIRUS-TEST-FILE"
datas[2] = "!$H+H*"
var i C.uint
for i = 0; i < x; i++ {
file, err := os.Create(fmt.Sprintf("./test%d.txt", i))
if err != nil {
log.Fatal(err)
}
defer file.Close()
for _, data := range datas {
file.WriteString(data)
}
}
return C.uint(0)
}
func main () {}
```
29 changes: 29 additions & 0 deletions DLL/lib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<stdio.h>

// Linux:
// __attribute__((visibility("default"))) int eicar(int x) {
__declspec( dllexport ) int eicar(int x) {
FILE *file;
char filename[12];

for(int i = 0; i < x; i++) {
snprintf(filename, 12, "test%d.txt", i);
file = fopen(filename, "w");

if(file == NULL) {
printf("file \"test%d.txt\" can't be opened\n", i);
return 1;
}

fprintf(
file,
"%sEICAR-STANDARD-ANTIVIRUS-TEST-FILE%s",
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$",
"!$H+H*"
);

fclose(file);
}

return 0;
}
36 changes: 36 additions & 0 deletions DLL/lib.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"log"
"os"
"fmt"
"C"
)

//export eicar
func eicar(x C.uint) C.uint {
var datas [3]string
datas[0] = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$"
datas[1] = "EICAR-STANDARD-ANTIVIRUS-TEST-FILE"
datas[2] = "!$H+H*"

var i C.uint

for i = 0; i < x; i++ {
file, err := os.Create(fmt.Sprintf("./test%d.txt", i))

if err != nil {
log.Fatal(err)
}

defer file.Close()

for _, data := range datas {
file.WriteString(data)
}
}

return C.uint(0)
}

func main () {}
18 changes: 18 additions & 0 deletions DLL/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::fs;

#[no_mangle]
pub extern fn eicar(x: i32) -> i32 {
let eicar = format!(
"{}EICAR-STANDARD-ANTIVIRUS-TEST-FILE{end}",
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$",
end="!$H+H*"
);

for x in 0..x {
fs::write(
format!("test{}.txt", x), eicar.clone()
);
}

return 0;
}
27 changes: 27 additions & 0 deletions Executable/EicarSpam.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<stdio.h>

int main() {
FILE *file;
char filename[12];

for(int i = 0; i < 300; i++) {
snprintf(filename, 12, "test%d.txt", i);
file = fopen(filename, "w");

if(file == NULL) {
printf("file \"test%d.txt\" can't be opened\n", i);
return 1;
}

fprintf(
file,
"%sEICAR-STANDARD-ANTIVIRUS-TEST-FILE%s",
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$",
"!$H+H*"
);

fclose(file);
}

return 0;
}
11 changes: 11 additions & 0 deletions Executable/EicarSpam.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
open System.IO
let start = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$"
let end_ = "!$H+H*"
let eicar = (
sprintf
$"{start}EICAR-STANDARD-ANTIVIRUS-TEST-FILE{end_}"
)
for i = 1 to 300 do
File.WriteAllText(
(sprintf "test%i.txt" i), eicar
)
29 changes: 29 additions & 0 deletions Executable/EicarSpam.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"log"
"os"
"fmt"
)


func main() {
var datas [3]string
datas[0] = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$"
datas[1] = "EICAR-STANDARD-ANTIVIRUS-TEST-FILE"
datas[2] = "!$H+H*"

for i := 0; i < 300; i++ {
file, err := os.Create(fmt.Sprintf("./test%d.txt", i))

if err != nil {
log.Fatal(err)
}

defer file.Close()

for _, data := range datas {
file.WriteString(data)
}
}
}
5 changes: 5 additions & 0 deletions Executable/EicarSpam.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$string = 'X5O!P%@AP[4\PZX54(P^)7CC)7}$_!$H+H*'.replace('_', 'EICAR-STANDARD-ANTIVIRUS-TEST-FILE')

for($i = 0; $i -lt 300; $i++){
Set-Content "test$i.txt" $string
}
17 changes: 17 additions & 0 deletions Executable/EicarSpam.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::fs;

fn main() -> std::io::Result<()> {
let eicar = format!(
"{}EICAR-STANDARD-ANTIVIRUS-TEST-FILE{end}",
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$",
end="!$H+H*"
);

for x in 0..301 {
fs::write(
format!("test{}.txt", x), eicar.clone()
)?;
}

Ok(())
}
Loading

0 comments on commit 84921e7

Please sign in to comment.