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
f39bdd51
Commit
f39bdd51
authored
Mar 08, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename crypto tasks to text tasks
parent
2e3fb55f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
39 deletions
+38
-39
configuration.yml
service/configuration.yml
+1
-1
ApplicationConfiguration.java
service/src/main/java/core/ApplicationConfiguration.java
+6
-6
TaskType.java
service/src/main/java/core/TaskType.java
+1
-1
TextTaskConfig.java
service/src/main/java/helpers/TextTaskConfig.java
+2
-4
TasksRepository.java
service/src/main/java/repositories/TasksRepository.java
+3
-3
TaskResource.java
service/src/main/java/resources/TaskResource.java
+25
-24
No files found.
service/configuration.yml
View file @
f39bdd51
...
@@ -57,7 +57,7 @@ teams:
...
@@ -57,7 +57,7 @@ teams:
password
:
"
1a7fcdd5a9fd433523268883cfded9d0"
#anteq1 md5
password
:
"
1a7fcdd5a9fd433523268883cfded9d0"
#anteq1 md5
email
:
"
antonigrzanka@gmail.com"
email
:
"
antonigrzanka@gmail.com"
crypto
Tasks
:
text
Tasks
:
-
name
:
"
Szyfro1"
-
name
:
"
Szyfro1"
text
:
"
Odszyfruj1"
text
:
"
Odszyfruj1"
flags
:
flags
:
...
...
service/src/main/java/core/ApplicationConfiguration.java
View file @
f39bdd51
package
core
;
package
core
;
import
helpers.
Crypto
TaskConfig
;
import
helpers.
Text
TaskConfig
;
import
helpers.WebTaskConfig
;
import
helpers.WebTaskConfig
;
import
io.dropwizard.Configuration
;
import
io.dropwizard.Configuration
;
import
objects.Team
;
import
objects.Team
;
...
@@ -15,7 +15,7 @@ public class ApplicationConfiguration extends Configuration
...
@@ -15,7 +15,7 @@ public class ApplicationConfiguration extends Configuration
private
String
dbName
;
private
String
dbName
;
private
String
flagHashMethod
;
private
String
flagHashMethod
;
private
List
<
Team
>
teams
;
private
List
<
Team
>
teams
;
private
List
<
CryptoTaskConfig
>
crypto
Tasks
;
private
List
<
TextTaskConfig
>
text
Tasks
;
private
List
<
WebTaskConfig
>
webTasks
;
private
List
<
WebTaskConfig
>
webTasks
;
private
List
<
User
>
admins
;
private
List
<
User
>
admins
;
...
@@ -29,14 +29,14 @@ public class ApplicationConfiguration extends Configuration
...
@@ -29,14 +29,14 @@ public class ApplicationConfiguration extends Configuration
this
.
admins
=
admins
;
this
.
admins
=
admins
;
}
}
public
List
<
CryptoTaskConfig
>
getCrypto
Tasks
()
public
List
<
TextTaskConfig
>
getText
Tasks
()
{
{
return
crypto
Tasks
;
return
text
Tasks
;
}
}
public
void
set
CryptoTasks
(
List
<
CryptoTaskConfig
>
crypto
Tasks
)
public
void
set
TextTasks
(
List
<
TextTaskConfig
>
text
Tasks
)
{
{
this
.
cryptoTasks
=
crypto
Tasks
;
this
.
textTasks
=
text
Tasks
;
}
}
public
List
<
WebTaskConfig
>
getWebTasks
()
public
List
<
WebTaskConfig
>
getWebTasks
()
...
...
service/src/main/java/core/TaskType.java
View file @
f39bdd51
...
@@ -5,7 +5,7 @@ package core;
...
@@ -5,7 +5,7 @@ package core;
*/
*/
public
enum
TaskType
{
public
enum
TaskType
{
WEB
(
"WEB"
),
WEB
(
"WEB"
),
CRYPTO
(
"CRYPTO
"
),
TEXT
(
"TEXT
"
),
UNDEFINED
(
"UNDEFINED"
);
UNDEFINED
(
"UNDEFINED"
);
private
final
String
type
;
private
final
String
type
;
...
...
service/src/main/java/helpers/
Crypto
TaskConfig.java
→
service/src/main/java/helpers/
Text
TaskConfig.java
View file @
f39bdd51
...
@@ -2,10 +2,8 @@ package helpers;
...
@@ -2,10 +2,8 @@ package helpers;
import
java.util.List
;
import
java.util.List
;
/**
public
class
TextTaskConfig
* Created by gpietrus on 23.02.2016.
{
*/
public
class
CryptoTaskConfig
{
private
String
name
;
private
String
name
;
private
int
level
;
private
int
level
;
private
String
text
;
private
String
text
;
...
...
service/src/main/java/repositories/TasksRepository.java
View file @
f39bdd51
...
@@ -2,7 +2,7 @@ package repositories;
...
@@ -2,7 +2,7 @@ package repositories;
import
core.ApplicationConfiguration
;
import
core.ApplicationConfiguration
;
import
core.TaskType
;
import
core.TaskType
;
import
helpers.
Crypto
TaskConfig
;
import
helpers.
Text
TaskConfig
;
import
helpers.WebTaskConfig
;
import
helpers.WebTaskConfig
;
import
objects.Flag
;
import
objects.Flag
;
import
objects.Solution
;
import
objects.Solution
;
...
@@ -79,7 +79,7 @@ public class TasksRepository implements Repository
...
@@ -79,7 +79,7 @@ public class TasksRepository implements Repository
@Override
@Override
public
void
initialize
()
public
void
initialize
()
{
{
List
<
CryptoTaskConfig
>
cryptoTasks
=
applicationConfiguration
.
getCrypto
Tasks
();
List
<
TextTaskConfig
>
cryptoTasks
=
applicationConfiguration
.
getText
Tasks
();
List
<
WebTaskConfig
>
webTasks
=
applicationConfiguration
.
getWebTasks
();
List
<
WebTaskConfig
>
webTasks
=
applicationConfiguration
.
getWebTasks
();
this
.
clean
();
this
.
clean
();
...
@@ -93,7 +93,7 @@ public class TasksRepository implements Repository
...
@@ -93,7 +93,7 @@ public class TasksRepository implements Repository
this
.
add
(
new
Task
(
this
.
add
(
new
Task
(
cryptoTaskConfig
.
getName
(),
cryptoTaskConfig
.
getName
(),
cryptoTaskConfig
.
getLevel
(),
cryptoTaskConfig
.
getLevel
(),
TaskType
.
CRYPTO
,
TaskType
.
TEXT
,
cryptoTaskConfig
.
getFlags
().
stream
()
cryptoTaskConfig
.
getFlags
().
stream
()
.
map
(
Flag:
:
new
)
.
map
(
Flag:
:
new
)
.
collect
(
Collectors
.
toList
()),
.
collect
(
Collectors
.
toList
()),
...
...
service/src/main/java/resources/TaskResource.java
View file @
f39bdd51
...
@@ -24,41 +24,24 @@ import java.io.InputStream;
...
@@ -24,41 +24,24 @@ import java.io.InputStream;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
* Created by gpietrus on 23.02.2016.
*/
@Singleton
@Singleton
@Path
(
value
=
"/task"
)
@Path
(
value
=
"/task"
)
public
class
TaskResource
{
public
class
TaskResource
{
protected
TasksRepository
tasksRepository
;
protected
TasksRepository
tasksRepository
;
@Inject
@Inject
public
TaskResource
(
TasksRepository
tasksRepository
)
{
public
TaskResource
(
TasksRepository
tasksRepository
)
{
this
.
tasksRepository
=
tasksRepository
;
this
.
tasksRepository
=
tasksRepository
;
}
}
public
String
readStream
(
InputStream
input
)
throws
IOException
{
try
(
BufferedReader
buffer
=
new
BufferedReader
(
new
InputStreamReader
(
input
)))
{
return
buffer
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
}
}
//todo: remove proxy resource
private
InputStream
proxyRequest
(
String
url
,
User
user
)
throws
IOException
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpGet
httpget
=
new
HttpGet
(
url
);
httpget
.
setHeader
(
"CTF-User"
,
user
.
getName
());
CloseableHttpResponse
execute
=
httpClient
.
execute
(
httpget
);
HttpEntity
entity
=
execute
.
getEntity
();
return
entity
.
getContent
();
}
@Path
(
"{task_level}"
)
@Path
(
"{task_level}"
)
@GET
@GET
public
Response
getTask
(
@Auth
User
user
,
public
Response
getTask
(
@Auth
User
user
,
final
@PathParam
(
"task_level"
)
int
taskLevel
)
throws
IOException
{
final
@PathParam
(
"task_level"
)
int
taskLevel
)
throws
IOException
{
Task
task
=
tasksRepository
.
get
(
taskLevel
);
Task
task
=
tasksRepository
.
get
(
taskLevel
);
if
(
task
==
null
)
{
if
(
task
==
null
)
{
return
Response
.
status
(
Response
.
Status
.
BAD_REQUEST
).
build
();
return
Response
.
status
(
Response
.
Status
.
BAD_REQUEST
).
build
();
...
@@ -67,7 +50,7 @@ public class TaskResource {
...
@@ -67,7 +50,7 @@ public class TaskResource {
String
taskText
=
null
;
String
taskText
=
null
;
switch
(
task
.
getTaskType
())
{
switch
(
task
.
getTaskType
())
{
case
CRYPTO
:
case
TEXT
:
taskText
=
((
TaskCryptoContent
)
task
.
getTaskContent
()).
getText
();
taskText
=
((
TaskCryptoContent
)
task
.
getTaskContent
()).
getText
();
break
;
break
;
case
WEB:
case
WEB:
...
@@ -76,4 +59,22 @@ public class TaskResource {
...
@@ -76,4 +59,22 @@ public class TaskResource {
}
}
return
Response
.
ok
().
entity
(
taskText
).
build
();
return
Response
.
ok
().
entity
(
taskText
).
build
();
}
}
//todo: remove proxy resource
private
InputStream
proxyRequest
(
String
url
,
User
user
)
throws
IOException
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpGet
httpget
=
new
HttpGet
(
url
);
httpget
.
setHeader
(
"CTF-User"
,
user
.
getName
());
CloseableHttpResponse
execute
=
httpClient
.
execute
(
httpget
);
HttpEntity
entity
=
execute
.
getEntity
();
return
entity
.
getContent
();
}
private
String
readStream
(
InputStream
input
)
throws
IOException
{
try
(
BufferedReader
buffer
=
new
BufferedReader
(
new
InputStreamReader
(
input
)))
{
return
buffer
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
}
}
}
}
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