Skip to content

Commit 7214f2b

Browse files
author
Marshall Lee Whittaker
committed
Try to fix some stuff with gtk.
1 parent 64b5aba commit 7214f2b

File tree

6 files changed

+38
-28
lines changed

6 files changed

+38
-28
lines changed

Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ endif
5151
if WITH_GTK
5252
ansvif_gtk_SOURCES = src/gtk.cpp src/popen2.cpp
5353
ansvif_gtk_LDADD = @GTK_LIBS@
54-
ansvif_gtk_CPPFLAGS = @GTK_CFLAGS@ -fpermissive
54+
ansvif_gtk_CPPFLAGS = @GTK_CFLAGS@ -D __NOTANDROID__
5555
endif
5656
ansvifdir = bin
5757
check: all

examples/nasty/lol

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
𝓣𝓱𝓮.𝓺𝓾𝓲𝓬𝓴.𝓫𝓻𝓸𝔀𝓷.𝓯𝓸𝔁.𝓳𝓾𝓶𝓹𝓼.𝓸𝓿𝓮𝓻.𝓽𝓱𝓮.𝓵𝓪𝔃𝔂.𝓭𝓸𝓰

src/gtk.cpp

+23-25
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ std::string no_null_s;
4444
std::string runcommand;
4545
std::string runcommanda;
4646
GtkWidget *caller_box;
47-
GtkTextBuffer *buffer;
4847
GtkTextIter iter;
4948
GtkWidget *buf_size_zero;
5049
GtkWidget *random_buffer_size;
@@ -77,6 +76,8 @@ GtkWidget *set_run_command_a;
7776
GtkWidget *runcoma;
7877
std::string ver = " -i ";
7978
std::string ansvif_loc = "ansvif ";
79+
//GtkTextBuffer *buffer;
80+
GtkWidget *buffer = gtk_entry_new();
8081

8182
int help_me(std::string mr_me) {
8283
std::cout << "ansvif v" << version << " -- A Not So Very Intelligent Fuzzer"
@@ -89,7 +90,9 @@ int help_me(std::string mr_me) {
8990
}
9091

9192

92-
static void destroy(GtkWidget *widget, gpointer *data) { gtk_main_quit(); }
93+
static void destroy(GtkWidget *widget, gpointer *data) {
94+
gtk_main_quit();
95+
}
9396

9497
std::string ansvif_str() {
9598
ansvif_call = ansvif_loc + ver + random_data + random_buffer_s + no_null_s + buffer_size +
@@ -172,18 +175,19 @@ const char *get_user() {
172175
}
173176

174177
static void fuzz_call() {
175-
/* put together the call to ansvif */
176-
int com_pid;
177-
FILE *fp = popen2(ansvif_str(), "r", com_pid, get_user());
178+
/* put together the call to ansvif */
179+
int ansvif_pid;
180+
FILE *fp = popen2(ansvif_str(), "r", ansvif_pid, get_user());
178181
char command_out[4096] = {0};
179182
std::stringstream output;
180183
while (read(fileno(fp), command_out, sizeof(command_out) - 1) != 0) {
181184
output << std::string(command_out);
182-
gtk_main_iteration_do(TRUE);
183185
memset(&command_out, 0, sizeof(command_out));
186+
gtk_main_iteration_do(TRUE);
184187
}
185-
gtk_text_buffer_set_text(buffer, output.str().c_str(), -1);
186-
pclose2(fp, com_pid);
188+
gtk_entry_set_text(GTK_ENTRY(buffer), output.str().c_str());
189+
pclose(fp);
190+
// execl("/bin/sh", "sh", "-c", ansvif_str().c_str(), NULL);
187191
}
188192

189193
static void template_selected(GtkWidget *w, GtkFileSelection *fs) {
@@ -351,21 +355,17 @@ const void set_no_null(void*) {
351355
}
352356

353357
/* Create a scrolled text area that displays a "message" */
354-
static GtkWidget *create_text(void) {
358+
GtkWidget *create_text(void) {
355359
GtkWidget *scrolled_window;
356360
GtkWidget *view;
357-
358361
view = gtk_text_view_new();
359-
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
360-
362+
// buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
361363
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
362364
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
363365
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
364-
365366
gtk_container_add(GTK_CONTAINER(scrolled_window), view);
366367
fuzz_call();
367368
gtk_widget_show_all(scrolled_window);
368-
369369
return (scrolled_window);
370370
}
371371

@@ -377,17 +377,16 @@ int main(int argc, char *argv[]) {
377377
GtkWidget *fuzz_it;
378378
GtkWidget *command_sel;
379379
GtkWidget *environ_sel;
380-
GtkWidget *logging_file;
381380
GtkWidget *template_sel;
382381
GtkWidget *ansvif_out;
383-
GtkWidget *text;
384382
GtkWidget *random_data_only;
385383
GtkWidget *b_size_label;
386384
GtkWidget *exit_code_label;
387385
GtkWidget *max_arg_label;
388386
GtkWidget *other_sep_label;
389387
GtkWidget *oo_sel;
390388
GtkWidget *log_sel;
389+
GtkWidget *text;
391390
gint tmp_pos;
392391
int c;
393392

@@ -451,7 +450,7 @@ int main(int argc, char *argv[]) {
451450
gtk_fixed_put(GTK_FIXED(opters), b_size_label, 540, 55);
452451
gtk_widget_show(b_size_label);
453452
gtk_widget_show(set_buf_size);
454-
/*A text box where we enter the custom crashcode */
453+
/* A text box where we enter the custom crashcode */
455454
set_exit_code = gtk_entry_new();
456455
gtk_entry_set_max_length(GTK_ENTRY(set_exit_code), 3);
457456
gtk_widget_set_size_request(GTK_WIDGET(set_exit_code), 50, 25);
@@ -489,8 +488,8 @@ int main(int argc, char *argv[]) {
489488
gtk_label_set_justify(GTK_LABEL(runcom_label), GTK_JUSTIFY_LEFT);
490489
gtk_fixed_put(GTK_FIXED(opters), runcom_label, 540, 175);
491490
gtk_widget_show(runcom_label);
492-
gtk_widget_show(set_run_command);
493-
/* Run command after */
491+
gtk_widget_show(set_run_command);
492+
/* Run command after */
494493
set_run_command_a = gtk_entry_new();
495494
gtk_widget_set_size_request(GTK_WIDGET(set_run_command_a), 50, 25);
496495
g_signal_connect(set_run_command_a, "activate", G_CALLBACK((gpointer)set_run_command_a_callback),
@@ -503,8 +502,7 @@ int main(int argc, char *argv[]) {
503502
gtk_widget_show(set_run_command_a);
504503
/* Make our template file selection */
505504
template_sel = gtk_button_new_with_label("Select Template");
506-
g_signal_connect(GTK_OBJECT(template_sel), "clicked",
507-
G_CALLBACK((gpointer)select_template), NULL);
505+
g_signal_connect(GTK_OBJECT(template_sel), "clicked", G_CALLBACK((gpointer)select_template), template_sel);
508506
gtk_fixed_put(GTK_FIXED(opters), template_sel, 30, 80);
509507
gtk_widget_show(template_sel);
510508
template_sel_t = gtk_entry_new();
@@ -614,25 +612,25 @@ int main(int argc, char *argv[]) {
614612
/* A toggle for turning buffer size 0 on and off */
615613
buf_size_zero = gtk_check_button_new_with_label("Buffer Size 0");
616614
g_signal_connect(GTK_OBJECT(buf_size_zero), "clicked",
617-
G_CALLBACK((gpointer)set_buffer_size), NULL);
615+
G_CALLBACK((gpointer)set_buffer_size), buf_size_zero);
618616
gtk_fixed_put(GTK_FIXED(opters), buf_size_zero, 30, 200);
619617
gtk_widget_show(buf_size_zero);
620618
/* A toggle for turning all random data on and off */
621619
random_data_only = gtk_check_button_new_with_label("Random Data Only");
622620
g_signal_connect(GTK_OBJECT(random_data_only), "clicked",
623-
G_CALLBACK((gpointer)set_random_data), NULL);
621+
G_CALLBACK((gpointer)set_random_data), random_data_only);
624622
gtk_fixed_put(GTK_FIXED(opters), random_data_only, 30, 220);
625623
gtk_widget_show(random_data_only);
626624
/* A toggle for turning buffer random buffer size on and off */
627625
random_buffer_size = gtk_check_button_new_with_label("Random Buffer Size");
628626
g_signal_connect(GTK_OBJECT(random_buffer_size), "clicked",
629-
G_CALLBACK((gpointer)set_random_size), NULL);
627+
G_CALLBACK((gpointer)set_random_size), random_buffer_size);
630628
gtk_fixed_put(GTK_FIXED(opters), random_buffer_size, 30, 180);
631629
gtk_widget_show(random_buffer_size);
632630
/* A toggle for turning non null on and off */
633631
no_null = gtk_check_button_new_with_label("No NULL In Fuzz");
634632
g_signal_connect(GTK_OBJECT(no_null), "clicked",
635-
G_CALLBACK((gpointer)set_no_null), NULL);
633+
G_CALLBACK((gpointer)set_no_null), no_null);
636634
gtk_fixed_put(GTK_FIXED(opters), no_null, 220, 180);
637635
gtk_widget_show(no_null);
638636
/* ansvif output goes here */

src/match_fault.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct BuffCont {
9090
int buf_size_int;
9191
bool rand_buf;
9292
} bufctl;
93+
9394
void log_hang(std::string write_file_n, std::string out_str_p,
9495
std::string out_str, std::string junk_file_of_args, int pid);
9596
void log_tail(std::string write_file_n, std::string junk_file_of_args,
@@ -124,6 +125,7 @@ get_out_str_pc(std::string env_str, std::string valgrind_str,
124125
std::string always_arg_before, std::string always_arg_after,
125126
std::string fuzz_after, std::string log_prefix,
126127
std::string before_command, bool write_pipe, bool verbose);
128+
int count_quotes(std::string quotes_str);
127129
bool match_seg(struct Options o, struct RunCommands runit, struct Monopoly go, struct BuffCont bufctl, struct Debug debugopts) {
128130
bool segged = false;
129131
std::vector<std::string> used_token;
@@ -429,6 +431,8 @@ bool match_seg(struct Options o, struct RunCommands runit, struct Monopoly go, s
429431
}
430432
}
431433
#endif
434+
if ((count_quotes(out_str.o) % 2) != 0) { return(false);}
435+
//std::cout << count_quotes(out_str.o) << std::endl;
432436
if (debugopts.debug == true) {
433437
/* write ALL the junk to STDOUT since we're in
434438
* debug mode

src/popen2.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ FILE *popen2(std::string command, std::string type, int &pid,
4848
*/
4949
// command = "DISPLAY=localhost:1 " + command;
5050
execl("/bin/su", "su", "-c", "/bin/sh", "-c", command.c_str(),
51-
low_lvl_user.c_str(), NULL);
51+
low_lvl_user.c_str(), NULL);
5252
} else {
5353
/* or just run it like we normally would */
54-
execl("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL);
54+
execl("/bin/sh", "sh", "-c", command.c_str(), NULL);
5555
}
5656
#endif
5757
#ifdef __ANDROID__

src/remove_chars.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ std::string remove_chars(const std::string &source, const std::string &chars) {
2020
}
2121
return (result);
2222
}
23+
24+
int count_quotes(std::string s) {
25+
unsigned int count = 0;
26+
for (unsigned int i = 0; i < s.size(); i++)
27+
if (s[i] == '\'') count++;
28+
return count;
29+
}

0 commit comments

Comments
 (0)