From 3ed34ae25164e4691240515fd70b297b56934a5b Mon Sep 17 00:00:00 2001 From: AndrewQuijano Date: Mon, 26 Aug 2024 20:14:51 -0400 Subject: [PATCH] combine with FBI bug inject --- tools/fbi/src/find_bug_inj.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tools/fbi/src/find_bug_inj.cpp b/tools/fbi/src/find_bug_inj.cpp index 6a6277d..01209fc 100644 --- a/tools/fbi/src/find_bug_inj.cpp +++ b/tools/fbi/src/find_bug_inj.cpp @@ -43,6 +43,7 @@ extern "C" { #include "lava_version.h" #include #include +#include #define CBNO_TCN_BIT 0 #define CBNO_CRD_BIT 1 @@ -1006,7 +1007,7 @@ int main (int argc, char **argv) { if (curtail == 0) { // Will be 0 unless specified on command line if (!project["curtail_fbi"].isUInt()) { curtail = 0; - }else{ + } else{ // null should never happen, if it does we'll violate an assert in the asUInt curtail = std::strtoul(project.get("curtail_fbi", Json::Value::null).asString().c_str(), 0, 0); } @@ -1016,8 +1017,31 @@ int main (int argc, char **argv) { inputfile = std::string(argv[4]); std::string db_name = project["db"].asString() + host.get("db_suffix", "").asString(); - db.reset(new odb::pgsql::database("postgres", "postgrespostgres", - db_name, "localhost")); + + const char* pgpass = std::getenv("PGPASS"); + const char* pguser = std::getenv("PGUSER"); + if (pgpass) { + // PGPASS environment variable is set, and pgpass points to its value. + std::cout << "PGPASS IS SET" << std::endl; + } else { + // PGPASS environment variable is not set. + std::cout << "PGPASS is not set" << std::endl; + exit(1); + } + + if (pguser) { + // PGUSER environment variable is set, and pgpass points to its value. + std::cout << "PGUSER IS SET: " << pguser << std::endl; + } else { + // PGUSER environment variable is not set. + std::cout << "PGUSER is not set" << std::endl; + exit(1); + } + + std::string DBHost("database"); + int DBPort = 5432; + db.reset(new odb::pgsql::database(pguser, pgpass, + db_name, DBHost, DBPort)); /* re-read pandalog, this time focusing on taint queries. Look for dead available data, attack points, and thus bug injection oppotunities