FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
compilebox/API/Payload/javaRunner.sh at master · codegrande/compilebox · GitHub
codegrande
/
compilebox
Public
forked from
remoteinterview/compilebox
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
compilebox
/
API
/
Payload
/
javaRunner.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
46 lines (38 loc) · 1.63 KB
Breadcrumbs
compilebox
/
API
/
Payload
/
javaRunner.sh
Copy path
File metadata and controls
executable file
·
46 lines (38 loc) · 1.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!
/usr/bin/env sh
#
#####################################################################################
#
This script is specifically made to handle the compilation of java
#
The idea is to cater with the difference of class name(s) inside file
#
and the file name itself when executing the java .class files
#
#
This script is executed after javac compiler has already compiled the file
#
into classes
#
#
The cd /usercode/ command is Docker case specific. Description is mentioned
#
below.
#
#
The script works as follows
#
1. Search the current directory for all files that have a .class extension
#
2. Run javap on the class name
#
The javap tool disassembles compiled Java™ files and prints
#
out a representation of the Java program. This may be helpful
#
when the original source code is no longer available on a system.
#
source: publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzaha/javap.htm
#
#
3. If the class contains the main function run the java command to run it and exit
#
4. This script only executes the first main function it finds
#
#
Inspired From: http://stackoverflow.com/a/8870863
#
#
######################################################################################
#
The folder which we mount on docker is named the usercode.
#
Move into the directory and execute the loop
cd
/usercode/
for
classfile
in
*
.class
;
do
classname=
${classfile
%
.
*
}
#
echo $classname
#
Execute fgrep with -q option to not display anything on stdout when the match is found
if
javap -public
$classname
|
fgrep -q
'
public static void main(java.lang.String[])
'
;
then
java
$classname
"
$@
"
exit
0
;
fi
done
Back
|
FazBrowse Home
|
New Git URL