Skip to content

Commit 2e4519f

Browse files
committed
move colors to from main.cpp to common.h
1 parent bbac5cf commit 2e4519f

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

include/Common.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ struct PortResult {
88
std::string service;
99
};
1010

11-
#endif // !COMMON_H
11+
#define START_PORT 1
12+
#define END_PORT 65535
13+
#define RED "\033[31m"
14+
#define BLUE "\033[36m"
15+
#define PINK "\033[33m"
16+
#define NC "\033[0m"
17+
18+
#endif // !COMMON_H

src/main.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,26 @@
55
#include <regex>
66
#include <string>
77

8+
#include "../include/Common.h"
89
#include "../include/Exporter.h"
910
#include "../include/Printer.h"
1011
#include "../include/Scanner.h"
1112

12-
#define START_PORT 1
13-
#define END_PORT 65535
14-
#define RED "\033[31m"
15-
#define BLUE "\033[36m"
16-
#define PINK "\033[33m"
17-
#define NC "\033[0m"
18-
1913
using namespace std;
2014

2115
#define THREAD_NUM 200
2216

2317
void print_usage() {
2418
std::cout << PINK << "Usage: xpscan <IP> [options]\n"
25-
<< NC
26-
<< BLUE << "Options:\n"
19+
<< NC << BLUE << "Options:\n"
2720
<< " --help Print this message\n"
2821
<< " --json Export results to [IP].json\n"
2922
<< " --txt Export results to [IP].txt\n"
3023
<< " --full Scan all 65535 ports\n"
3124
<< NC;
3225
}
3326

34-
int main(int argc, char* argv[]) {
27+
int main(int argc, char *argv[]) {
3528
// check if at least one arg is passed
3629
if (argc < 2 || std::strcmp(argv[1], "--help") == 0) {
3730
print_usage();
@@ -87,14 +80,17 @@ int main(int argc, char* argv[]) {
8780
// Calculate elapsed time
8881
std::chrono::duration<double> diff = end - start;
8982
std::cout << "\n"
90-
<< BLUE << "[!] Scan finished in " << diff.count() << "s" << NC << std::endl;
83+
<< BLUE << "[!] Scan finished in " << diff.count() << "s" << NC
84+
<< std::endl;
9185

9286
Exporter exporter; // Uses default config path because i extracted the config file path as a parameter
9387
if (exportJson) exporter.saveToJson(input.ip, scanner.getResults());
9488
if (exportTxt) exporter.saveToText(input.ip, scanner.getResults());
9589

9690
if (!exportJson && !exportTxt) {
97-
std::cout << PINK << "[!] No export flags set. Use --json or --txt to save results." << NC << std::endl;
91+
std::cout << PINK
92+
<< "[!] No export flags set. Use --json or --txt to save results."
93+
<< NC << std::endl;
9894
}
9995

10096
return 0;

0 commit comments

Comments
 (0)