Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

problem


buddywithgol's Avatar
Member
0 0

is it possible to create a file in java and run it automatically? like if i create a .bat file using java, can i run it using java?:D


scrptnnj's Avatar
Member
0 0

I dont know about java but in other languages like python and php there are built in system functions markup os.system("./run.sh")


ellipsis's Avatar
...
0 -1

buddywithgol wrote: is it possible to create a file in java and run it automatically? like if i create a .bat file using java, can i run it using java?:D

Java doesn't give you access to the underlying system and outside of the cwd. You can start a process with Java much like you would with C#. So if you know the path to the executable, you can start it using Java. You can also create a file with Java and write text to it… You can also detect the operating system, so you can know what sort of file to create (shell script or batch file).

Process proc = Runtime.getRuntime().exec("\\Path\\To\\Batch.bat");

USE GOOGLE TO YOUR ADVANTAGE.


Arabian's Avatar
Member
0 0

ellipsis wrote: [quote]buddywithgol wrote: is it possible to create a file in java and run it automatically? like if i create a .bat file using java, can i run it using java?:D

Java doesn't give you access to the underlying system and outside of the cwd. [/quote]

False: Java's Native Interface

JNI allows direct access to assembly, C code, and C++ code. JNI may make winAPI calls and create DLL's.

Completely out of the scope of OP's knowledge.


ellipsis's Avatar
...
0 -1

Arabian wrote: [quote]ellipsis wrote: [quote]buddywithgol wrote: is it possible to create a file in java and run it automatically? like if i create a .bat file using java, can i run it using java?:D

Java doesn't give you access to the underlying system and outside of the cwd. [/quote]

False: Java's Native Interface

JNI allows direct access to assembly, C code, and C++ code. JNI may make winAPI calls and create DLL's.

Completely out of the scope of OP's knowledge.[/quote]

Why would you need JNI to do what he wants to do?

He wants to create a text file, fill it with code, and execute it. He can do this and more with just Java.

I'll submit a code to the Java code bank and link here.


ellipsis's Avatar
...
0 -1

buddywithgol wrote: is it possible to create a file in java and run it automatically? like if i create a .bat file using java, can i run it using java?:D

www.hellboundhackers.org/code/create-a-script-file-write-code-to-it-and-execute-in-java-2044_.html

If the operating system is Windows, it will create a batch script, if UNIX/Mac/Linux it will create a bash script. It will write "dir" to the batch script or "ls" to the bash script. Then it will execute the script. It will also delete the script if it fails to execute. All in Java.

EDIT: I'm stupid when it comes to BBCode or whatever these tags are. So just copy and paste the URL.


Arabian's Avatar
Member
0 0

ellipsis wrote:

Why would you need JNI to do what he wants to do?

He wants to create a text file, fill it with code, and execute it. He can do this and more with just Java.

I'll submit a code to the Java code bank and link here.

I was replying in response to this bit:

Java doesn't give you access to the underlying system and outside of the cwd.

…which is false.


ellipsis's Avatar
...
0 -1

Arabian wrote: [quote]ellipsis wrote:

Why would you need JNI to do what he wants to do?

He wants to create a text file, fill it with code, and execute it. He can do this and more with just Java.

I'll submit a code to the Java code bank and link here.

I was replying in response to this bit:

Java doesn't give you access to the underlying system and outside of the cwd.

…which is false.

[/quote]

Okay. Yes, JNI allows C++ and other languages to be implemented in Java code. Congratulations…


Arabian's Avatar
Member
0 0

Don't be bitter. It's applicable if OP were attempting to write malicious code for his/her target operating system, and in that regard (which i believe he was hinting at with the .bat script reference), he'd be able to use knowledge of JNI to implement his vector.

Now, this IS fucking retarded to do in Java, but possible nonetheless.


tuere816's Avatar
Member
0 0

Arabian wrote: Don't be bitter. It's applicable if OP were attempting to write malicious code for his/her target operating system, and in that regard (which i believe he was hinting at with the .bat script reference), he'd be able to use knowledge of JNI to implement his vector.

Now, this IS fucking retarded to do in Java, but possible nonetheless.

I remember when i knew very little about stuff , not that i know much now.. i used to think the only method to execute something with files was to write a .bat file script or use Windows Explorer, maybe OP just has a bit lack of knowledge and no malicious intentions ….

=================================================================

THE NEED OF ME TO SEE THE BEST IN EVERY1././ :)


tuere816's Avatar
Member
0 0

Arabian wrote: Don't be bitter. It's applicable if OP were attempting to write malicious code for his/her target operating system, and in that regard (which i believe he was hinting at with the .bat script reference), he'd be able to use knowledge of JNI to implement his vector.

Now, this IS fucking retarded to do in Java, but possible nonetheless.

I remember when i knew very little about stuff , not that i know much now.. i used to think the only method to execute something with files was to write a .bat file script or use Windows Explorer, maybe OP just has a bit lack of knowledge and no malicious intentions ….

=================================================================

THE NEED OF ME TO SEE THE BEST IN EVERY1././ :)


ellipsis's Avatar
...
0 -1

Arabian wrote: Don't be bitter. It's applicable if OP were attempting to write malicious code for his/her target operating system, and in that regard (which i believe he was hinting at with the .bat script reference), he'd be able to use knowledge of JNI to implement his vector.

Now, this IS fucking retarded to do in Java, but possible nonetheless.

Pardon me for being bitter, Arabian. I'm thinking that if he doesn't even know file i/o, he probably has zero malicious intent. I gave him a link to some decent Java. I graduated from my votech in '08, so I'm not a Java Jedi or anything, but I gave him some useful tools that he could use in delivering OS specific payloads of malicious code. The only thing required is a JVM and JRE on whatever he's trying to attack with whatever he decides to write in the future with whatever malicious intentions he may have, whenever he decides to write some malicious software. Who knows what his intentions are.

@OP, hope the link points you in the right direction.