-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhackertyper.cpp
More file actions
185 lines (151 loc) · 5.59 KB
/
Copy pathhackertyper.cpp
File metadata and controls
185 lines (151 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#include <bits/types/struct_timeval.h>
#include <stdlib.h>
#include <sys/select.h>
#include <termios.h>
#include <unistd.h>
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string.h>
#include <fstream>
#include <sstream>
#include <random>
#include <vector>
#include <dirent.h>
#include <regex>
// Function to list all matching files in a directory
std::vector<std::string> listMatchingFiles(const std::string& directory, const std::string& pattern) {
std::vector<std::string> result;
DIR* dir;
struct dirent* entry;
std::regex filePattern(pattern);
if ((dir = opendir(directory.c_str())) != nullptr) {
while ((entry = readdir(dir)) != nullptr) {
std::string filename = entry->d_name;
if (std::regex_match(filename, filePattern)) {
result.push_back(directory + "/" + filename);
}
}
closedir(dir);
}
return result;
}
// Function to read text from file
std::string readTextFromFile(const std::string& filename) {
std::ifstream file(filename);
if (!file.is_open()) {
std::cerr << "Error opening file: " << filename << std::endl;
return "";
}
std::stringstream buffer;
buffer << file.rdbuf();
return buffer.str();
}
// Function to set up MS-DOS retro style
void setupMSDOSStyle() {
// Clear screen
system("clear");
// Set light gray text (DOS-like colors) without blue background
std::cout << "\033[0m\033[37m";
// Print DOS-like header
std::cout << "C:\\>HACK.EXE" << std::endl;
std::cout << "Microsoft(R) MS-DOS(R) Version 6.22" << std::endl;
std::cout << "(C)Copyright Microsoft Corp 1981-1994." << std::endl << std::endl;
std::cout << "Initializing system breach protocol..." << std::endl;
std::cout << "Establishing secure connection..." << std::endl << std::endl;
}
// Function to display text with proper formatting
void displayText(const std::string& text) {
std::istringstream stream(text);
std::string line;
std::cout << "\033[32;1m"; // Set bright green color
while(std::getline(stream, line)) {
std::cout << line << std::endl;
}
std::cout << "\033[0m"; // Reset color
}
int main(int argc, char* argv[]) {
// Set default characters per keystroke
int charsToAdd = 5; // Increased from 3 to 5 for more characters per keystroke
// Allow command-line override
if (argc > 1) {
charsToAdd = std::atoi(argv[1]);
if (charsToAdd <= 0) charsToAdd = 5;
}
// Get all hackertext files
std::vector<std::string> hackerTextFiles = listMatchingFiles(".", "hackertext[0-9]*.txt");
// If no files found, look for the original file
if (hackerTextFiles.empty()) {
hackerTextFiles.push_back("hackertext.txt");
}
// Randomly select a file
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> fileDist(0, hackerTextFiles.size() - 1);
std::string selectedFile = hackerTextFiles[fileDist(gen)];
// Read text from the randomly selected file
std::string str = readTextFromFile(selectedFile);
if (str.empty()) {
std::cerr << "Failed to read text file or file is empty." << std::endl;
return 1;
}
struct termios oldSettings, newSettings;
int i = 0;
std::string text = "";
// Save current terminal settings
tcgetattr(fileno(stdin), &oldSettings);
newSettings = oldSettings;
newSettings.c_lflag &= (~ICANON & ~ECHO);
tcsetattr(fileno(stdin), TCSANOW, &newSettings);
// Setup MS-DOS style interface
setupMSDOSStyle();
// Show prompt with blinking cursor
std::cout << "C:\\HACK>";
std::cout.flush();
// Short delay to simulate system loading
usleep(500000);
// Main loop - run until user presses Ctrl+C
bool running = true;
while (running) {
// Non-blocking check for input
fd_set readfds;
struct timeval tv;
FD_ZERO(&readfds);
FD_SET(STDIN_FILENO, &readfds);
tv.tv_sec = 0;
tv.tv_usec = 1000; // Very small timeout
if (select(STDIN_FILENO + 1, &readfds, NULL, NULL, &tv) > 0) {
char c;
if (read(STDIN_FILENO, &c, 1) > 0) {
// Exit if Ctrl+C is pressed
if (c == 3) {
running = false;
} else {
// Clear screen
system("clear");
// Reset text color for DOS-like look (no blue background)
std::cout << "\033[0m\033[37m";
// DOS-like header
std::cout << "C:\\HACK>DECRYPT.EXE" << std::endl;
std::cout << "SCANNING NETWORK..." << std::endl << std::endl;
// Add more text when any key is pressed
for (int j = 0; j < charsToAdd && i < str.length(); j++, i++) {
text += str[i];
}
if (i >= str.length()) {
i = 0;
}
// Display text with proper formatting
displayText(text);
// Add blinking cursor at the end
std::cout << "\033[37m_\033[0m" << std::endl;
}
}
}
}
// Restore terminal settings and colors
std::cout << "\033[0m";
system("clear");
tcsetattr(fileno(stdin), TCSANOW, &oldSettings);
return 0;
}