Skip to content

Commit

Permalink
add test.class src (#42)
Browse files Browse the repository at this point in the history
* add test src

* fix README

---------

Co-authored-by: Farida Gaifutdinova <[email protected]>
  • Loading branch information
gfarida and Farida Gaifutdinova authored Apr 28, 2023
1 parent 4c5ee45 commit 1b2d219
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Examples/Crusher/Linux/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
В системе должна быть установлена JAVA 8 версии. Если Ваш проект не принимает на вход файл, то необходимо написать driver,
на вход которому передается файл с данными, а он в свою очередь запускает JAVA приложение, которое Вы хотите фаззить.

В данном примере скомпилированный driver и jar файл с проектом находятся в директории `target`.
В данном примере исходный код driver и jar файл с проектом находятся в директории `target`.

Находясь в данной директории, запустите скрипт `./instrumentation.sh` для инструментации приложения(driver-а) и используемых библиотек,
он принимает один аргумент - путь до директории `kelinci`.
Находясь в данной директории, запустите скрипт `./instrumentation.sh` для компиляции driver-а и инструментации приложения(driver-а) и используемых библиотек,
он принимает 2 аргумента - путь до директории `kelinci` и до компилятора `javac`.

# Фаззинг

Expand Down
Binary file removed Examples/Crusher/Linux/java/bin/test.class
Binary file not shown.
9 changes: 6 additions & 3 deletions Examples/Crusher/Linux/java/instrumentation.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/bin/bash

if [[ "$#" -ne 1 ]]; then
echo "Usage: ./instrumentation.sh <path/to/kelinci>"
if [[ "$#" -ne 2 ]]; then
echo "Usage: ./instrumentation.sh <path/to/kelinci> <path/to/javac> "
exit 1
fi

KELINCI=$1
JAVAC=$2

mkdir bin
cp target/test.class bin/test.class

echo "compile driver"
${JAVAC} -cp target/commons-math3-3.6.1.jar target/test.java -d bin

echo "instrument project and libraries"

Expand Down
Binary file removed Examples/Crusher/Linux/java/target/test.class
Binary file not shown.
31 changes: 31 additions & 0 deletions Examples/Crusher/Linux/java/target/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import org.apache.commons.math3.complex.Complex;
import org.apache.commons.math3.distribution.NormalDistribution;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;

import java.io.*;

import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;

public class test {
public static void main(String[] args) throws Exception {
FileInputStream is = new FileInputStream(args[0]);
Scanner scanner = new Scanner(is);
int q1 = 0, q2 = 0;
q1 = scanner.nextInt();
q2 = scanner.nextInt();

NormalDistribution normalDistribution = new NormalDistribution(q1, q2);
Complex first = new Complex(q1, q2);

q1 = scanner.nextInt();
q2 = scanner.nextInt();

Complex second = new Complex(q2, q1);

Complex power = first.pow(second);
double randomValue = normalDistribution.sample();
}

}

0 comments on commit 1b2d219

Please sign in to comment.