annotate win95kg.cpp @ 88:4b8fd5492092

why does this work? committer: GitHub <noreply@github.com>
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Thu, 28 Jul 2022 20:09:42 -0400
parents 3487aa65ca56
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
1 /* Windows 95 Keygen - 11/24/20
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
2 By Paper
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
3 not sure if this will work fully, but from what i've seen it works well enough
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
4
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
5 going back on this a few months later, wew this code sucks ass
42
1c81c5106b59 Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 41
diff changeset
6 fixed the OEM key generation, the medium article i read was wrong about it
1
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
7 */
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
8 #include <ctime>
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
9 #include <cstdlib>
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
10 #include <cstring>
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
11 #include <iomanip>
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
12 #include <iostream>
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
13 #include <string>
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
14
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
15 int a(), b(), c(), d(), e();
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
16 int main(int argc, char * argv[]) {
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
17 int endpoint, startpoint, sadsong;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
18 srand((unsigned) time(NULL));
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
19 if (argc >= 2) {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
20 if (strcmp(argv[1], "--office") == 0) {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
21 startpoint = c();
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
22 sadsong = 4;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
23 } else if (strcmp(argv[1], "--oem") == 0) {
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
24 std::cout << std::setw(5) << std::setfill('0') << d();
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
25 std::cout << "-OEM-";
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
26 std::cout << std::setw(7) << std::setfill('0') << e() << "-";
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
27 std::cout << std::setw(5) << std::setfill('0') << (rand() % 100000);
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
28 return 0;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
29 } else if (strcmp(argv[1], "--normal") == 0) {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
30 startpoint = a();
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
31 sadsong = 3;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
32 } else {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
33 std::cout << "usage: " << argv[0] << " [--normal] [--oem] [--office]";
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
34 return 0;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
35 }
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
36 } else {
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
37 std::cout << "usage: " << argv[0] << " [--normal] [--oem] [--office]";
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
38 return 0;
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
39 }
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
40 endpoint = b();
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
41 std::cout << std::setw(sadsong) << std::setfill('0') << startpoint << "-";
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
42 std::cout << std::setw(7) << std::setfill('0') << endpoint;
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
43 return 0;
1
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
44 }
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
45
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
46 int a() {
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
47 int num = rand() % 1000;
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
48 while ((num == 333) || (num == 444) || (num == 555) || (num == 666) || (num == 777) || (num == 888) || (num == 999)) {
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
49 num = rand() % 1000;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
50 }
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
51 while ((num % 3) != 0) {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
52 num = num + 1;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
53 }
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
54 return num;
1
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
55 }
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
56
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
57 int b() {
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
58 int first_digits;
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
59 int last_digit;
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
60 int second_segment = 5;
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
61 while (second_segment % 7 != 0) {
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
62 first_digits = rand() % 1000000;
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
63 last_digit = rand() % 10;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
64 while ((last_digit == 0) || (last_digit >= 8)) {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
65 last_digit = rand() % 10;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
66 }
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
67 second_segment = std::stoi(std::to_string(first_digits) + std::to_string(last_digit));
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
68 }
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
69 return second_segment;
1
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
70 }
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
71
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
72 int c() {
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
73 int new_site = rand() % 1000;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
74 int ez_pwned = new_site % 10 + 1;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
75 while (ez_pwned >= 10) {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
76 ez_pwned = ez_pwned - 10;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
77 }
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
78 return std::stoi(std::to_string(new_site) + std::to_string(ez_pwned));
1
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
79 }
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
80
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
81 int d() {
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
82 const char * years[] = {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
83 "95",
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
84 "96",
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
85 "97",
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
86 "98",
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
87 "99",
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
88 "00",
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
89 "01",
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
90 "02",
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
91 "03"
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
92 };
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
93 int index = (rand() % 9);
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
94 const char * year = years[index];
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
95 return std::stoi(std::to_string((rand() % 366) + 1) + year);
1
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
96 }
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
97
3
fcbeb8097ad3 win95kg.cpp - add check for last digit in e()
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 1
diff changeset
98 int e() {
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
99 int first_digits;
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
100 int last_digit;
43
3487aa65ca56 Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 42
diff changeset
101 int second_segment;
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
102 int sum = 1;
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
103 while (sum % 7 != 0) {
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
104 sum = 0;
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
105 first_digits = rand() % 10000;
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
106 last_digit = rand() % 10;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
107 while ((last_digit == 0) || (last_digit >= 8)) {
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
108 last_digit = rand() % 10;
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
109 }
41
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
110 std::string second_segment_p1 = (std::to_string(first_digits) + std::to_string(last_digit));
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
111 for(char &c :second_segment_p1) {
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
112 sum += c - '0';
37f231f85a67 add tabs to some c++ files and fix win95kg.cpp
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
113 }
5
9241ce1e5abe Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 3
diff changeset
114 }
43
3487aa65ca56 Update win95kg.cpp
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 42
diff changeset
115 return std::stoi(second_segment_p1);
1
05978f04869b Add files via upload
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
116 }