Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions server/src/session.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define _POSIX_C_SOURCE 200809L

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -28,8 +30,12 @@ int conf_cmd_file(t_client *client)
{
char *conf;

fclose(client->session->conf.file);
client->session->conf.file = 0;
VERBOSE(printf("conf_cmd_file called with line: %s\n", client->session->conf.line));
if (client->session->conf.file)
{
fclose(client->session->conf.file);
client->session->conf.file = 0;
}
conf = client->session->conf.line + 5;
if (file_exists(conf))
{
Expand All @@ -41,6 +47,10 @@ int conf_cmd_file(t_client *client)
strlen(client->session->conf.line));
*/
}
else
{
VERBOSE(printf("Config file does not exist: %s\n", conf));
}
return (session_do_step(client));
}

Expand Down Expand Up @@ -79,6 +89,11 @@ void session_get_line(t_client *client)
client->session->conf.file = fopen(conf, "r");
VERBOSE(printf("\033[%d;1m<%03d> - conf : %s\033[m\n",
COLOR(client->session->id), client->session->id, conf));
if (!client->session->conf.file)
{
VERBOSE(printf("Failed to open conf file: %s\n", conf));
return;
}
}
if (!fgets(client->session->conf.line, BUF_SIZE, client->session->conf.file))
{
Expand All @@ -93,6 +108,9 @@ void session_get_line(t_client *client)

int session_do_step(t_client *client)
{
int ret;

VERBOSE(printf("session_do_step called with line: %s\n", client->session->conf.line));
if (client->action == ACTION_READY && !client->session->attack.in_progress)
session_get_line(client);
client->session->attack.step++;
Expand All @@ -104,7 +122,12 @@ int session_do_step(t_client *client)
COLOR(client->session->id), client->session->id,
client->session->attack.step));
*/
session_parse_line(client);
ret = session_parse_line(client);
if (ret == 0)
{
VERBOSE(printf("Ignoring unknown command safely\n"));
// Add any safe handling here if needed
}
return (1);
}

Expand Down