Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
9858b9ef
Commit
9858b9ef
authored
Apr 05, 2016
by
Dominik Rosiek
Browse files
Options
Browse Files
Download
Plain Diff
flag md5
parents
2ad9d9e6
e78511c8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
27 deletions
+62
-27
WebTask.java
.../com/telephoners/krakyournet/ctf/beans/tasks/WebTask.java
+3
-2
TaskResource.java
...m/telephoners/krakyournet/ctf/resources/TaskResource.java
+12
-2
loginController.js
...esources/assets/statics/js/controllers/loginController.js
+3
-3
taskController.js
...resources/assets/statics/js/controllers/taskController.js
+1
-1
tasksController.js
...esources/assets/statics/js/controllers/tasksController.js
+8
-1
main.js
service/src/main/resources/assets/statics/js/main.js
+27
-6
apiProvider.js
...main/resources/assets/statics/js/providers/apiProvider.js
+4
-4
authenticationService.js
...urces/assets/statics/js/services/authenticationService.js
+2
-2
task.html
service/src/main/resources/assets/task.html
+1
-5
tasks.html
service/src/main/resources/assets/tasks.html
+1
-1
No files found.
service/src/main/java/com/telephoners/krakyournet/ctf/beans/tasks/WebTask.java
View file @
9858b9ef
...
...
@@ -21,7 +21,7 @@ import java.util.List;
public
class
WebTask
extends
Task
{
private
String
url
;
private
static
final
Joiner
URL_JOINER
=
Joiner
.
on
(
"/"
);
private
static
final
Joiner
URL_JOINER
=
Joiner
.
on
(
"/"
);
//todo
public
WebTask
(
String
name
,
int
level
,
String
description
,
List
<
Flag
>
flags
,
String
url
)
{
...
...
@@ -35,7 +35,8 @@ public class WebTask extends Task
public
String
getTextForUser
(
User
user
,
String
path
)
throws
IOException
{
String
url
=
URL_JOINER
.
join
(
getUrl
(),
path
);
// String url = URL_JOINER.join(getUrl(), path); //todo: rethink
String
url
=
getUrl
()
+
path
;
return
StreamUtils
.
readStream
(
proxyRequest
(
url
,
user
));
}
...
...
service/src/main/java/com/telephoners/krakyournet/ctf/resources/TaskResource.java
View file @
9858b9ef
...
...
@@ -4,12 +4,15 @@ import com.telephoners.krakyournet.ctf.beans.User;
import
com.telephoners.krakyournet.ctf.beans.tasks.Task
;
import
com.telephoners.krakyournet.ctf.repositories.TasksRepository
;
import
io.dropwizard.auth.Auth
;
import
org.glassfish.jersey.server.ContainerRequest
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.container.ContainerRequestContext
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.Response
;
import
java.io.IOException
;
...
...
@@ -29,10 +32,17 @@ public class TaskResource
@GET
public
Response
getTask
(
@Auth
User
user
,
final
@PathParam
(
"task_level"
)
int
taskLevel
,
final
@PathParam
(
"path"
)
String
path
)
throws
IOException
final
@PathParam
(
"path"
)
String
path
,
@Context
ContainerRequestContext
containerRequestContext
)
throws
IOException
{
Task
task
=
tasksRepository
.
getByLevel
(
taskLevel
);
//todo: refactor, path not necessary in textTasks
return
Response
.
ok
().
entity
(
task
.
getTextForUser
(
user
,
path
)).
build
();
ContainerRequest
context
=
(
ContainerRequest
)
containerRequestContext
;
String
query
=
context
.
getRequestUri
().
getQuery
();
String
fullPath
=
path
;
if
(
query
!=
null
)
{
//todo: refactor
fullPath
=
fullPath
+
"?"
+
query
;
}
return
Response
.
ok
().
entity
(
task
.
getTextForUser
(
user
,
fullPath
)).
build
();
}
}
service/src/main/resources/assets/statics/js/controllers/loginController.js
View file @
9858b9ef
(
function
(){
angular
.
module
(
'ctfApp'
).
controller
(
'LoginController'
,
[
'$scope'
,
'$rootScope'
,
'$location'
,
'AuthenticationService'
,
'$window'
,
'NavbarService'
,
function
(
$scope
,
$rootScope
,
$location
,
AuthenticationService
,
$window
,
NavbarService
)
{
[
'$scope'
,
'$rootScope'
,
'$location'
,
'AuthenticationService'
,
'$window'
,
'NavbarService'
,
'AppSettings'
,
function
(
$scope
,
$rootScope
,
$location
,
AuthenticationService
,
$window
,
NavbarService
,
AppSettings
)
{
// reset login status
AuthenticationService
.
clearCredentials
();
...
...
@@ -13,7 +13,7 @@
$location
.
path
(
'/'
);
AuthenticationService
.
setCredentials
(
$scope
.
username
,
$scope
.
password
,
response
.
team
);
// redirect to additional external auth point
$window
.
location
.
href
=
"http://"
+
$scope
.
username
+
":"
+
$scope
.
password
+
"@52.28.244.24:8080/api/v1/auth"
;
$window
.
location
.
href
=
AppSettings
.
getApiAddressWithCredentials
(
$scope
.
username
,
$scope
.
password
)
+
'/auth'
;
}
else
{
Materialize
.
toast
(
'Błąd logowania! Spróbuj jeszcze raz.'
,
5000
,
'toast-error'
);
$scope
.
dataLoading
=
false
;
...
...
service/src/main/resources/assets/statics/js/controllers/taskController.js
View file @
9858b9ef
(
function
(){
angular
.
module
(
'ctfApp'
).
controller
(
'TaskController'
,
[
'$scope'
,
'$stateParams'
,
'APIProvider'
,
'AppSettings'
,
function
(
$scope
,
$stateParams
,
APIProvider
,
AppSettings
)
{
$scope
.
submitUnknown
=
false
;
$scope
.
apiAddress
=
'http://'
+
AppSettings
.
apiAddress
;
$scope
.
apiAddress
=
AppSettings
.
getApiAddress
()
;
$scope
.
selectedTaskId
=
$stateParams
.
taskLevel
;
// console.log('SELECTED TASK ID', $scope.selectedTaskId);
APIProvider
.
getTaskById
(
$scope
.
selectedTaskId
,
function
(
data
){
...
...
service/src/main/resources/assets/statics/js/controllers/tasksController.js
View file @
9858b9ef
(
function
(){
angular
.
module
(
'ctfApp'
).
controller
(
'TasksController'
,
[
'$scope'
,
'$http'
,
'APIProvider'
,
'AppSettings'
,
function
(
$scope
,
$http
,
APIProvider
,
AppSettings
)
{
$scope
.
apiAddress
=
AppSettings
.
apiAddress
;
$scope
.
apiAddress
=
AppSettings
.
getApiAddress
()
;
APIProvider
.
getTasks
(
function
(
data
){
// console.log(data);
$
.
each
(
data
,
function
(
key
){
data
[
key
].
short_description
=
data
[
key
].
description
.
split
(
" "
).
slice
(
0
,
6
).
join
(
" "
).
concat
(
"..."
);
});
APIProvider
.
getMyCompletedLevelsList
(
function
(
completed
){
$
.
each
(
data
,
function
(
key
,
task
){
if
(
completed
.
indexOf
(
task
.
level
)
!==
-
1
){
...
...
@@ -13,7 +18,9 @@
}
});
});
$scope
.
tasks
=
data
;
});
}]);
})();
\ No newline at end of file
service/src/main/resources/assets/statics/js/main.js
View file @
9858b9ef
...
...
@@ -37,12 +37,31 @@
}]);
app
.
factory
(
'AppSettings'
,
function
()
{
var
dev
=
"localhost:8080/api/v1"
,
prod
=
"52.28.244.24:8080/api/v1"
;
app
.
factory
(
'AppSettings'
,
[
'$http'
,
function
(
$http
)
{
// fallback into defaults, if everything fails, world collapses, hell freezes and /startup will not resolve
var
domainName
=
'52.25.28.64'
,
port
=
"http"
,
schema
=
8080
;
return
{
apiAddress
:
prod
initAPI
:
function
(){
$http
.
get
(
'/api/v1/startup'
).
success
(
function
(
data
){
console
.
debug
(
data
);
domainName
=
data
.
domainName
;
port
=
data
.
port
;
schema
=
data
.
schema
;
});
},
getApiAddress
:
function
(){
return
schema
+
"://"
+
domainName
+
":"
+
port
+
"/api/v1"
;
},
getApiAddressWithCredentials
:
function
(
username
,
password
){
return
schema
+
"://"
+
username
+
":"
+
password
+
"@"
+
domainName
+
":"
+
port
+
"/api/v1"
;
}
};
});
}
]
);
app
.
config
([
'$httpProvider'
,
function
(
$httpProvider
)
{
...
...
@@ -59,8 +78,10 @@
}]);
app
.
run
([
'$rootScope'
,
'$location'
,
'$cookieStore'
,
'$http'
,
'NavbarService'
,
function
(
$rootScope
,
$location
,
$cookieStore
,
$http
,
NavbarService
)
{
app
.
run
([
'$rootScope'
,
'$location'
,
'$cookieStore'
,
'$http'
,
'NavbarService'
,
'AppSettings'
,
function
(
$rootScope
,
$location
,
$cookieStore
,
$http
,
NavbarService
,
AppSettings
)
{
AppSettings
.
initAPI
();
$
(
".button-collapse"
).
sideNav
();
...
...
service/src/main/resources/assets/statics/js/providers/apiProvider.js
View file @
9858b9ef
...
...
@@ -5,7 +5,7 @@
getScores
:
function
(
callback
){
$http
.
get
(
'http://'
+
AppSettings
.
apiAddress
+
'/solutions/all'
).
$http
.
get
(
AppSettings
.
getApiAddress
()
+
'/solutions/all'
).
success
(
function
(
data
)
{
scores
=
data
;
if
(
callback
)
callback
(
data
);
...
...
@@ -13,7 +13,7 @@
},
getTasks
:
function
(
callback
){
$http
.
get
(
'http://'
+
AppSettings
.
apiAddress
+
'/tasks'
).
$http
.
get
(
AppSettings
.
getApiAddress
()
+
'/tasks'
).
success
(
function
(
data
)
{
this
.
getMySolutions
(
function
(
solutions
){
if
(
solutions
){
...
...
@@ -69,7 +69,7 @@
* @param callback
*/
getMyCompletedLevelsList
:
function
(
callback
){
$http
.
get
(
'http://'
+
AppSettings
.
apiAddress
+
'/solutions/my/completed'
).
$http
.
get
(
AppSettings
.
getApiAddress
()
+
'/solutions/my/completed'
).
success
(
function
(
data
)
{
if
(
callback
)
callback
(
data
);
});
...
...
@@ -82,7 +82,7 @@
* @returns {HttpPromise}
*/
submitFlag
:
function
(
level
,
flag
){
return
$http
.
post
(
'http://'
+
AppSettings
.
apiAddress
+
'/solutions/'
+
level
,
flag
);
return
$http
.
post
(
AppSettings
.
getApiAddress
()
+
'/solutions/'
+
level
,
flag
);
}
};
}]);
...
...
service/src/main/resources/assets/statics/js/services/authenticationService.js
View file @
9858b9ef
...
...
@@ -15,7 +15,7 @@
*/
login
:
function
(
username
,
password
,
callback
)
{
$http
.
get
(
'http://'
+
username
+
":"
+
password
+
"@"
+
AppSettings
.
apiAddress
+
'/whoami'
,
{
$http
.
get
(
AppSettings
.
getApiAddressWithCredentials
(
username
,
password
)
+
'/whoami'
,
{
headers
:
{
'Authorization'
:
'Basic '
+
Base64
.
encode
(
username
+
':'
+
password
)}
})
.
then
(
function
(
response
)
{
...
...
@@ -35,7 +35,7 @@
*/
logout
:
function
(
callback
)
{
$http
.
get
(
'http://'
+
'askdjfadsf'
+
':'
+
'adsfasskdjfadsf'
+
'@'
+
AppSettings
.
apiAddress
+
'/whoami'
,
{
$http
.
get
(
AppSettings
.
getApiAddressWithCredentials
(
'askdjfadsf'
,
'adsfasskdjfadsf'
)
+
'/whoami'
,
{
headers
:
{
'Authorization'
:
'Basic '
+
Base64
.
encode
(
'askdjfadsf'
+
':'
+
'adsfasskdjfadsf'
)}
}).
then
(
function
(
response
){
this
.
clearCredentials
();
...
...
service/src/main/resources/assets/task.html
View file @
9858b9ef
...
...
@@ -18,11 +18,7 @@
</div>
</span>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
{{task.description}}
</p>
</div>
</div>
...
...
service/src/main/resources/assets/tasks.html
View file @
9858b9ef
...
...
@@ -10,7 +10,7 @@
<i
ng-if=
"task.taskType === 'WEB'"
class=
"fa fa-globe"
alt=
"Zadanie webowe"
></i>
{{task.name}}
</span>
<p>
Poziom {{task.level}}.
Super zadanie.
</p>
<p>
Poziom {{task.level}}.
{{task.short_description}}
</p>
</div>
<div
class=
"card-action"
>
<a
href=
"#/task/{{task.level}}"
>
Przejdź do zadania
</a></td>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment