Skip to content

Commit

Permalink
STUFF
Browse files Browse the repository at this point in the history
  • Loading branch information
wetw0rk authored and wetw0rk committed Apr 15, 2019
1 parent 57a39e6 commit aefabca
Show file tree
Hide file tree
Showing 173 changed files with 3,238 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Edabit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Edabit

The AWAE syllabus appears to include many real world CVE's meaning we will likely be doing source code review, or chaining vulnerabilities in order to obtain code execution. Depending on the bug we may need to deploy custom payloads etc, so I decided to spend a week per language specifically Java, JavaScript, and PHP. Since I know Python I decided to skip it, however if you have little to no experience in Python I recommend spending a week on it as well.

It's important you are able to do the following in each language:
- Create a function
- Call a function
- Create a class
- Call a class
- Debug issues

## Links

https://edabit.com/
20 changes: 20 additions & 0 deletions Edabit/java/eight.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Create a function that takes a two strings and returns true if
the first argument ends with the second argument; otherwise
return false.
*/

public class Program
{
public static boolean checkEnding(String str1, String str2)
{
return str1.endsWith(str2);
}

public static void main(String[] args)
{
System.out.printf("%b\n", checkEnding("abc", "bc"));
}
}
25 changes: 25 additions & 0 deletions Edabit/java/eighteen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Create a method that takes an integer as an argument. Add up all the numbers
from 1 to the number you passed to the function. For example, if the input is
4 then your function should return 10 because 1 + 2 + 3 + 4 = 10.
*/

public class Program
{
public static int addUp(int num)
{
int f = num;
for (int i = 0; i < num; i++)
f += i;
return f;
}

public static void main(String[] args)
{
System.out.printf("%d\n", addUp(4));
System.out.printf("%d\n", addUp(13));
System.out.printf("%d\n", addUp(600));
}
}
24 changes: 24 additions & 0 deletions Edabit/java/eleven.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
There is a single operator in Java capable of providing the remainder
of a division operation. Two numbers are passed as parameters. The
first provider divided by the second parameter will have a remainder,
possiby zero. Return that value.
*/


public class Program
{
public static int myMethod(int a, int b)
{
return a % b;
}

public static void main(String[] args)
{
System.out.printf("%d\n", myMethod(1, 3));
System.out.printf("%d\n", myMethod(-9, 45));
System.out.printf("%d\n", myMethod(5, 5));
}
}
19 changes: 19 additions & 0 deletions Edabit/java/fifteen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Create a method that takes a string and returns the word count.
The string will be a sentence.
*/

public class Program
{
public static int countWords(String s)
{
return s.split(" ").length;
}

public static void main(String[] args)
{
System.out.printf("%d\n", countWords("Just an example here move along"));
}
}
32 changes: 32 additions & 0 deletions Edabit/java/five.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Create a method that takes an array of integers. Return the largest integer in the array.
we could have also done:
```
import static java.util.Arrays.stream;
public static int findLargestNum(int[] nums) {
return stream(nums).max().getAsInt();
}
```
*/

public class Program
{
public static int findLargestNum(int[] nums)
{
int largest = nums[0];
for (int i = 0; i < nums.length; i++)
if (nums[i] > largest)
largest = nums[i];
return largest;
}

public static void main(String[] args)
{
System.out.printf("%s\n", findLargestNum(new int[]{4,5,1,3}));
}
}
24 changes: 24 additions & 0 deletions Edabit/java/four.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Take an array of integers (positive or negative or both) and return
the sum of the absolute value of each element.
*/

import java.util.stream.*;

public class Program
{
public static int getAbsSum(int[] nums)
{
int sum = 0;
for (int i = 0; i < nums.length; i++)
sum += Math.abs(nums[i]);
return sum;
}

public static void main(String[] args)
{
System.out.printf("%d\n", getAbsSum(new int[]{2, -1, 4, 8, 10}));
}
}
19 changes: 19 additions & 0 deletions Edabit/java/fourteen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Create a method that takes a string as its argument
and returns the string in reversed order.
*/

public class Program
{
public static String reverse(final String str)
{
return new StringBuffer(str).reverse().toString();
}

public static void main(String[] args)
{
System.out.printf("%s\n", reverse("ls"));
}
}
25 changes: 25 additions & 0 deletions Edabit/java/nine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Create a function that takes an array and a string as
arguments and return the index of the string.
*/

public class Program
{
public static int findIndex(String[] arr, String str)
{
int i;
for (i = 0; i < arr.length; i++)
if (arr[i] == str)
break;
return i;
}

public static void main(String[] args)
{
System.out.printf("%d\n",
findIndex(new String[]{"hi", "edabit", "fgh", "abc"}, "fgh")
);
}
}
38 changes: 38 additions & 0 deletions Edabit/java/nineteen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Create a method that takes an array of integers and returns an array where
each integer is the sum of itself + all previous numbers in the array.
*/

import java.util.Arrays;

public class Program
{
public static int[] cumulativeSum(int[] nums)
{
int[] arr = new int[nums.length];
int j = 0;

for (int i = 0; i < (nums.length); i++)
{
arr[i] = nums[i];
while (j != i)
arr[i] += nums[j++];
j = 0;
}

return arr;
}

public static void main(String[] args)
{
int[] arr1 = new int[]{1, 2, 3};
int[] arr2 = new int[]{1, -2, 3};
int[] arr3 = new int[]{3, 3, -2, 408, 3, 3};

System.out.println(Arrays.toString(cumulativeSum(arr1)));
System.out.println(Arrays.toString(cumulativeSum(arr2)));
System.out.println(Arrays.toString(cumulativeSum(arr3)));
}
}
23 changes: 23 additions & 0 deletions Edabit/java/one.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Create a method that takes an integer as an argument and returns
"even" for even integers and "odd" for odd integers.
Run using:
java one.java
*/

public class Program
{
// internal function
public static String isEvenOrOdd(int num)
{
return ((num % 2) == 0) ? "even" : "odd";
}
// main function
public static void main(String[] args)
{
System.out.printf("%s\n", isEvenOrOdd(3));
}
}
23 changes: 23 additions & 0 deletions Edabit/java/seven.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Create a method that takes an integer as its only argument
and returns true if it's less than or equal to zero,
otherwise return false.
*/

public class Program
{
public static boolean lessThanOrEqualToZero(int num)
{
return (num <= 0) ? true : false;
}

public static void main(String[] args)
{
System.out.printf("%b\n", lessThanOrEqualToZero(5));
System.out.printf("%b\n", lessThanOrEqualToZero(0));
System.out.printf("%b\n", lessThanOrEqualToZero(-2));
System.out.printf("%b\n", lessThanOrEqualToZero(1));
}
}
37 changes: 37 additions & 0 deletions Edabit/java/seventeen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Create a function that takes a string and returns the
number (count) of vowels contained within it.
*/

public class Program
{
// matchesCount: count occurences of char c in String str1
public static int matchesCount (String str1, char c)
{
int count = 0;
for (int i = 0; i < str1.length(); i++)
if (str1.toLowerCase().charAt(i) == c)
count++;
return count;
}

public static int getCount(String str)
{
char vowels[] = {'a', 'e', 'i', 'o', 'u'};
int finalc = 0;

for (int i = 0; i < vowels.length; i++)
finalc += matchesCount(str, vowels[i]);

return finalc;
}

public static void main(String[] args)
{
System.out.printf("%d\n", getCount("Celebration"));
System.out.printf("%d\n", getCount("Palm"));
System.out.printf("%d\n", getCount("Prediction"));
}
}
20 changes: 20 additions & 0 deletions Edabit/java/six.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Create a method that takes an array of integers and returns the smallest number in the set.
*/

import static java.util.Arrays.stream;

public class Program
{
public static int findSmallestInt(int[] args)
{
return stream(args).min().getAsInt();
}

public static void main(String[] args)
{
System.out.printf("%s\n", findSmallestInt(new int[]{34,15,88,2}));
}
}
37 changes: 37 additions & 0 deletions Edabit/java/sixteen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Christmas Eve is almost upon us, so naturally we need to prepare
some milk and cookies for Santa! Create a method that accepts a
GregorianCalendar object and returns true if it's Christmas Eve
(December 24th) and false otherwise.
Note:
could have just compared to return val for example 11...
*/

import java.util.GregorianCalendar;

public class Program
{
public static boolean timeForMilkAndCookies(GregorianCalendar date)
{
GregorianCalendar daTime = new GregorianCalendar(2013, 11, 24);

return (
daTime.get(daTime.DATE) == date.get(date.DATE) &&
daTime.get(daTime.MONTH) == date.get(date.MONTH)
);
}

public static void main(String[] args)
{
GregorianCalendar ac = new GregorianCalendar(2013, 11, 24);
GregorianCalendar bc = new GregorianCalendar(2013, 0, 23);
GregorianCalendar cc = new GregorianCalendar(3000, 11, 24);

System.out.printf("%b\n", timeForMilkAndCookies(ac));
System.out.printf("%b\n", timeForMilkAndCookies(bc));
System.out.printf("%b\n", timeForMilkAndCookies(cc));
}
}
Loading

0 comments on commit aefabca

Please sign in to comment.