## Java Code to Zip all folders in a particular folder.

A small utility code to create multiple zip files for all folders in the a particular folder.

for example

- c:/path/to/folder
-> folder 1
-> folder 2
-> folder 3
-> folder 4


Output:

- c:/path/to/folder
-> folder 1
-> folder 2
-> folder 3
-> folder 4
-> folder 1.zip
-> folder 2.zip
-> folder 3.zip
-> folder 4.zip


original source: https://goo.gl/sp0bqr

## Problem:

Reversi is a two player board game which is played on a 10 x 10 grid of cells. Each player has an allocated color, Black ( First Player ) or White ( Second Player ) being conventional. Players take turns placing a stone of their color on a single cell. A player must place a stone on the board, in such a position that there exists at least one straight (horizontal, vertical, or diagonal) occupied line between the new stone and another stone of same color, with one or more contiguous other color stone between them.

During a game, any stone of the opponent’s color that are in a straight line and bounded by the stone just placed and another stone of the current player’s color are turned over to the current player’s color. The game will end when the board is completely filled or both the players don’t have any move left. At the end of the game the player with majority of stone will win.

We will play it on an 10 x 10 grid. The top left of the grid is [0,0] and the bottom right is [9,9]. The rule is that a cell[i,j] is connected to any of top, left, right, or bottom cell.

Input:
The input will be a 10 x 10 matrix consisting only of 0,1,2 or 3. Then another line will follow which will contain a number – 1 or 2 which is your player id.

In the given matrix, top-left is [0,0] and bottom-right is [9,9].

In cell[row,column], row increases from top to bottom and column increases from left to right.

The cell marked 0 means it doesn’t contain any stones. The cell marked 1 means it contains first player’s stone which is Black in color. The cell marked 2 means it contains second player’s stone which is white in color. The cell marked 3 means it is a valid place for player whose turn it is.

Output:
Print the coordinates of the cell separated by space, where you want to play your move. You must take care that you don’t print invalid coordinates. For example, [1] might be a valid coordinate in the game play if cell[i,j]=3, but [10] will never be. Also if you play an invalid move or your code exceeds the time/memory limit while determining the move, you lose the game.

Starting state
The starting state of the game is the state of the board before the game starts.

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 2 1 0 0 0 0
0 0 0 0 1 2 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0


First Input
This is the input give to the first player at the start of the game.

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 3 0 0 0 0 0
0 0 0 3 2 1 0 0 0 0
0 0 0 0 1 2 3 0 0 0
0 0 0 0 0 3 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1


Scoring
The scores are calculated by running tournament of all submissions. Your latest submission will be taken into tournament. Scores are assigned according to the Glicko-2 rating system. For more information and questions, see Bot problem judge.

SAMPLE INPUT

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 3 0 0 0 0 0
0 0 0 3 2 1 3 0 0 0
0 0 0 0 2 2 0 0 0 0
0 0 0 3 1 1 2 3 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1
SAMPLE OUTPUT
4 3

Explanation

This is player 1’s turn, and the player puts his/her stone in cell[4,3].
After his/her move the state of game becomes:

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 3 0 3 0 0 0 0
0 0 0 1 1 1 0 0 0 0
0 0 0 3 1 2 0 0 0 0
0 0 0 3 1 1 2 0 0 0
0 0 0 1 0 3 0 0 0 0
0 0 3 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0


This state will be fed as input to program of player 2.

Time Limit:1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme:Marks are awarded if any testcase passes.
Allowed Languages:C, CPP, CLOJURE, CSHARP, D, ERLANG, FSHARP, GO, GROOVY, HASKELL, JAVA, JAVA8, JAVASCRIPT, JAVASCRIPT_NODE, LISP, LISP_SBCL, LUA, OBJECTIVEC, OCAML, OCTAVE, PASCAL, PERL, PHP, PYTHON, PYTHON3, R, RACKET, RUBY, RUST, SCALA, SWIFT, VB

## How to find e-mail address source

Some times we need to find the source location of the sender of an email, or even the IP Address of the sender. This may not be a general case requirement, but even for the fun of it, or just out of curiosity, the recipient would want to search for such information.

I decided to try this on one of the spam advertisers:

In the following steps you’ll learn how to find and copy an email header and paste it into the Trace Email Analyzer to get the sender’s IP address and track the source.

Would you like to track down (or trace) where an email that you received came from?

This Trace Email tool can help you do precisely that. It works by examining the header that is a part of the emails you receive to find the IP address. If you read the IP Lookup page, you’ll get a clear idea of what information an IP address can reveal.

## What email provider do you use?

To find the IP address of a received email you’re curious about, open the email and look for the header details. How you find that email’s header depends on the email program you use. Do you use Gmail or Yahoo? Hotmail or Outlook?

For example, if you’re a Gmail user, here are the steps you’d take:

1. Open the message you want to view
3. Select “Show Original” to open a new window with the full headers

## STEPS TO TRACING AN EMAIL:

1. Get instructions for locating a header for your email provider here
2. Open the email you want to trace and find its header
3. Copy the header, then paste it into the Trace Email Analyzer below
4. Press the “Get Source” button
5. Scroll down below the box for the Trace Email results!

You should know that in some instances people send emails with false or “forged” headers, which are common in spam and unwanted or even malicious e-mail. Our Trace Email tool does not and cannot detect forged e-mail. That’s why that person forged the header to begin with!

Results:

## Problem Statement

There are N sequences. All of them are initially empty, and you are given a variable lastans = 0. You are given Q queries of two different types:

• 1 x y” – Insert y at the end of the ((x XOR lastans) mod N)th sequence.
• 2 x y” – Print the value of the (y mod size)th element of the ((x XOR lastans) mod N)th sequence. Here, $size$ denotes the size of the related sequence. Then, assign this integer to lastans.

Note: You may assume that, for the second type of query, the related sequence will not be an empty sequence. Sequences and the elements of each sequence are indexed by zero-based numbering.

You can get more information about XOR from Wikipedia. It is defined as ^ in most of the modern programming languages.

Input Format

The first line consists of $N$, number of sequences, and $Q$, number of queries, separated by a space. The following $Q$ lines contains one of the query types described above.

Constraints
1 < N,Q < 10^5
0 < x < 10^9
0 < y < 10^9

Output Format

For each query of type two, print the answer on a new line.

Sample Input

2 5
1 0 5
1 1 7
1 0 3
2 1 0
2 1 1


Sample Output

7
3


Explanation

The first sequence is 5, 3 and the second sequence is 7.

## WordPress User Registration Spam

Recently I had enabled the option to register on TechUtils.in as a subscriber to the login page. It’s an easy option just go to the Admin Section> Settings> General.

Check the Option “Anyone can register” and click on save.

This was the easy part thinking that I could get users and later if they wish to contribute then, I would just change their role. Thus easy public contribution to my Blog.

And within hours I had about 300+ users registering on my blog as subscribers.

The peculiar part was that every time someone registered, they would change their password. As an admin i would receive the mail instantly that the user has lost their password and have changed it.

At first I was amused, but then later curious that why would each user change their password as soon as they register.

On digging I found various articles. One that sticks out was this one

It seems that many people are facing the same issue and sites like

komatoz.net
gawab.com
yandex.ru
mail.ru
inbox.ru

Users from these sites may be budding hackers or just fun spammers…but for blog owners they are just useless irritations.

How to lose them?

There are a few ways for that:

• ##### Use of the .htaccess File

.htAccess file has an in-built design for such issues.

Options -Indexes

order allow,deny

deny from 24.1.39.117
deny from 38.99.101.151
deny from 58.65.237.113
deny from 58.65.239.146
deny from 61.152.95.162
deny from 64.233.179.101
deny from 64.86.69.6
deny from 64.94.4.196

deny from 66.235.180.189
deny from 72.249.100.188
deny from 75.126.3.177
deny from 78.110.160.130
deny from 85.225.117.179
deny from 87.118.112.50
deny from 88.255.69.10
deny from 89.149.227.193
deny from 89.149.241.229
deny from 89.207.216.211

deny from 160.114.38.82
deny from 190.2.0.2
deny from 192.116.79.226

deny from 195.2.114.31
deny from 195.2.114.32
deny from 195.245.119.76
deny from 195.225.178.15

deny from 203.162.2.137
deny from 205.158.160.76
deny from 208.187.80.135

deny from 210.14.128.112
deny from 210.14.128.172
deny from 210.22.158.132
deny from 212.175.13.169

deny from 216.240.152.9
deny from 217.20.115.118
deny from 218.61.16.8

allow from all

• ##### Use of Akismet

Most folk use anyway as it’s part of the default WordPress install. The activation is fairly simple and even though the say select a plan, it can still be used as free.

• Just head over to the activation plan selection page.
• Select the basic plan
• drag the slider to the leftmost, till you wipe the smile off that smiley.
• click get API Key.
• activate Akismet
• Enjoy. In case there comes an Oops moment where people still trickle through and you don’t even want them…upgrade your plan…

Source

## Building a Huge Dictionary, for Dictionary Attacks in Hacking

For Wifi Hack: Crack WPA2 Or WPA Password, we generally use a dictionary attack, a brute force type attack in Kali Linux. It has to certain some complex computations and processings but by the end of it it still needs a good word dictionary to actually be able to attack and be successful.

I have just made an attempt to be able to create an exhaustive word list, via permutation and combination of all possible characters based on a US-English Keyboard.

Below is the code for the same:

package in.techutils.wordlist.generator;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Tester {

public static List combos = new ArrayList();
public static int fileIndex = 0;
public static final String PATH = "C:/Projects/techutils.in/dictAttack/combo set";

static void printAllKLength(char set[], int k) {
int n = set.length;
printAllKLengthRec(set, "", n, k);
}

static void printAllKLengthRec(char set[], String prefix, int n, int k) {

if (k == 0) {
if (combos.size() == 999999) {
System.out.println("Writing to File..." + (++fileIndex));
fileDump();
combos.clear();
}
return;
}
for (int i = 0; i < n; ++i) { String newPrefix = prefix + set[i]; printAllKLengthRec(set, newPrefix, n, k - 1); } } public static void main(String[] args) { char set1[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 !~:;_@#\$%^&*(){}[]-_=+|?".toCharArray(); int k = 8; printAllKLength(set1, k); } public static void fileDump() { PrintWriter out = null; try { out = new PrintWriter(PATH +" "+ fileIndex + ".txt"); StringBuffer sb = new StringBuffer(""); for (String comb : combos) { sb.append(comb).append("\n"); } out.println(sb); } catch (Exception e) { System.out.println("error for file: " + PATH +" "+ fileIndex + "--->"
+ e);
} finally {
if (out != null) {
out.close();
}
}

}

}`

The Algorithm stores 999999 keys per file leading upto 8MB per file.

Also this process is for 8 key characters only. It will be more time taking in 8->16 characters.
The above code is lengthy approach but I think it must be extensive enough. I had to kill the process midway(1 hr into the execution) and ended up with 74.5 GB.

If anyone can run this and get it completed, i think we will be having the complete dictionary attack set….:)