Skip to content

Commit d5486ef

Browse files
rootroot
root
authored and
root
committedApr 12, 2012
Engine advancements
-Added a new function, usage that summarizes the differents flags and their use. -Done mutex opérations inside the worker threads
1 parent 27f00b9 commit d5486ef

8 files changed

+74
-12
lines changed
 

‎.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CMakeCache.txt
2+
CMakeFiles
3+
cmake_install.cmake
4+
dirbuster-ng
5+
Makefile
6+

‎Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ CMAKE_COMMAND = /usr/bin/cmake
3636
RM = /usr/bin/cmake -E remove -f
3737

3838
# The top-level source directory on which CMake was run.
39-
CMAKE_SOURCE_DIR = /home/wintermew/Projets/dirbuster-ng
39+
CMAKE_SOURCE_DIR = /home/cgame/Projects/dirbuster-ng
4040

4141
# The top-level build directory on which CMake was run.
42-
CMAKE_BINARY_DIR = /home/wintermew/Projets/dirbuster-ng
42+
CMAKE_BINARY_DIR = /home/cgame/Projects/dirbuster-ng
4343

4444
#=============================================================================
4545
# Targets provided globally by CMake.
@@ -107,9 +107,9 @@ rebuild_cache/fast: rebuild_cache
107107

108108
# The main all target
109109
all: cmake_check_build_system
110-
$(CMAKE_COMMAND) -E cmake_progress_start /home/wintermew/Projets/dirbuster-ng/CMakeFiles /home/wintermew/Projets/dirbuster-ng/CMakeFiles/progress.marks
110+
$(CMAKE_COMMAND) -E cmake_progress_start /home/cgame/Projects/dirbuster-ng/CMakeFiles /home/cgame/Projects/dirbuster-ng/CMakeFiles/progress.marks
111111
$(MAKE) -f CMakeFiles/Makefile2 all
112-
$(CMAKE_COMMAND) -E cmake_progress_start /home/wintermew/Projets/dirbuster-ng/CMakeFiles 0
112+
$(CMAKE_COMMAND) -E cmake_progress_start /home/cgame/Projects/dirbuster-ng/CMakeFiles 0
113113
.PHONY : all
114114

115115
# The main clean target

‎src/dict.h

+6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ const char* def_dict[] = {
33

44
"include",
55
"config",
6+
"conf",
67
"images",
8+
"img",
79
"js",
10+
"styles",
11+
"css",
12+
"stylesheets",
13+
"templates",
814
"javascript",
915
"wp-content",
1016
"wp-admin"

‎src/dirbuster-ng

-8.79 KB
Binary file not shown.

‎src/dirbuster-ng.c

+55-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int parse_arguments(int argc, char **argv)
99
int index;
1010
int c;
1111
int opterr = 0;
12-
while ((c = getopt(argc, argv, "qvw:d:h:n:")) != -1) {
12+
while ((c = getopt(argc, argv, "hqvw:d:n:")) != -1) {
1313
switch (c) {
1414
case 'v':
1515
return;
@@ -20,7 +20,7 @@ int parse_arguments(int argc, char **argv)
2020
conf0.quiet = 1;
2121
break;
2222
case 'h':
23-
conf0.host = optarg;
23+
usage();
2424
break;
2525
default:
2626
break;
@@ -48,27 +48,67 @@ int load_dict() {
4848
void* dbng_engine(void* queue_arg) {
4949

5050
struct queue* db_queue = (struct queue*) queue_arg;
51+
extern dbng_config conf0;
5152
char * url;
5253
CURL *curl;
53-
CURLcode response;
54-
54+
CURLcode response;
55+
char *wl;
5556
curl = curl_easy_init();
5657

5758
while(db_queue->head) {
58-
curl_easy_setopt(curl, CURLOPT_URL,"http://google.com");
59+
60+
//we lock the queue's mutex, get the entry then unlock
61+
pthread_mutex_lock(db_queue->mutex);
62+
//memcpy sur entry -> wl sinon pb race cond ??
63+
wl = db_queue->head->entry;
64+
queue_rem(db_queue);
65+
pthread_mutex_unlock(db_queue->mutex);
66+
67+
//we construct the url given host and wl
68+
url = (char*) malloc((strlen(conf0.host) + strlen(wl) +2) * sizeof(char) );
69+
strncpy(url,conf0.host,strlen(conf0.host));
70+
strncat(url,"/",1 * sizeof(char));
71+
strncat(url,wl,strlen(wl));
72+
73+
curl_easy_setopt(curl, CURLOPT_URL,url);
5974
response = curl_easy_perform(curl);
6075
if (response != 404 ) {
6176
output("FOUND %s (response code %d)\n",url,response);
6277
}
78+
79+
curl_easy_cleanup(curl);
80+
free(url);
6381
}
6482
}
6583

84+
85+
6686
int init_workers() {
6787
extern dbng_config conf0;
6888
conf0.workers = (pthread_t*) malloc(conf0.nb_workers * sizeof(pthread_t));
6989
}
7090

7191

92+
int init_workloads(struct queue* db_queue) {
93+
94+
extern dbng_config conf0;
95+
if (NULL == conf0.dict) {
96+
97+
}
98+
}
99+
100+
int usage() {
101+
102+
printf("Usage: dirbuster-ng [options...] <url>\n\
103+
Options:\n -w <workers>\tDefines the number of threads to use to make the attack\n\
104+
-d <dict>\tLoads an external textfile to use as a dictionary\n\
105+
-q\t Enable quiet mode (relevent only with the -W flag)\n\
106+
-h\t Prints this help then exits\n\
107+
-v\t Prints the program version then exits\n");
108+
109+
exit(0);
110+
}
111+
72112
int version() {
73113
printf("{Dirbuster NG 0.1} (c)2012 WintermeW\n");
74114
}
@@ -77,6 +117,16 @@ int version() {
77117
int main(int argc, char **argv)
78118
{
79119
extern dbng_config conf0;
120+
struct queue* db_queue;
121+
122+
if (argc < 2) usage();
123+
124+
conf0.host = argv[argc -1];
125+
126+
db_queue = queue_new();
127+
db_queue->mutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
128+
pthread_mutex_init(db_queue->mutex,NULL);
129+
80130
parse_arguments(argc,argv);
81131
if (!conf0.quiet) version();
82132
//debug

‎src/dirbuster-ng.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <curl/curl.h>
1212

1313

14-
#define DEFAULT_WORKERS 5
14+
#define DEFAULT_WORKERS 8
1515

1616
dbng_config conf0;
1717

‎src/dirbuster-ng_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
typedef struct dbng_config {
44

55
int nb_workers;
6-
char external_dict[1024];
76
uint8_t quiet;
87
pthread_t* workers;
8+
char *dict;
99
char* host;
1010

1111
} dbng_config;

‎src/queue.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct elt {
1111
struct queue {
1212
struct elt *head;
1313
struct elt *tail;
14-
pthread_mutex_t * mutex;
14+
pthread_mutex_t* mutex;
1515
};
1616

1717
struct queue *queue_add(struct queue *,char*);

0 commit comments

Comments
 (0)
Please sign in to comment.