pvpgn-twilight 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +24 -0
- data/docs/pvpgn-twilight.txt +30 -0
- data/examples/pvpgn_test.rb +2 -0
- data/ext/extconf.rb +5 -0
- data/ext/pvpgn.cpp +206 -0
- data/pvpgn-twilight.gemspec +14 -0
- metadata +62 -0
data/Changes
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Version 0.0.1
|
2
|
+
- First Release
|
3
|
+
|
4
|
+
Version 0.0.2
|
5
|
+
- Some Fixes to the gemspec
|
6
|
+
|
7
|
+
Version 0.0.3
|
8
|
+
- Removed some static variables from the code
|
9
|
+
- Improved the gem
|
10
|
+
|
11
|
+
Version 0.0.4
|
12
|
+
- More Improvements
|
13
|
+
- Added a change log
|
14
|
+
- Added RDocs
|
15
|
+
|
16
|
+
Version 0.0.5
|
17
|
+
- Improved RDocs a little
|
18
|
+
|
19
|
+
Version 0.0.6
|
20
|
+
- Tweaked RDocs
|
21
|
+
- Tweaked source a little
|
22
|
+
|
23
|
+
Version 0.0.7
|
24
|
+
- Created GitHub repository
|
@@ -0,0 +1,30 @@
|
|
1
|
+
= Description
|
2
|
+
A library allowing communication with pvpgn, as well as some optimized versions of pvpgn
|
3
|
+
utility functions
|
4
|
+
|
5
|
+
= Synopsis
|
6
|
+
require 'pvpgn'
|
7
|
+
|
8
|
+
puts PVPGN::BNHash('hello') #will hash to: 2e0236a3649381fe99cdce4b5b59adffa3167c7b
|
9
|
+
|
10
|
+
= Module functions
|
11
|
+
PVPGN.BNHash(string_to_hash)
|
12
|
+
This will return a string containing the 5 DWORD/UINT long hash required for pvpgn
|
13
|
+
logon authentication, it is automatically converted to lower case
|
14
|
+
|
15
|
+
= Known Bugs
|
16
|
+
None that I know of.
|
17
|
+
|
18
|
+
= License
|
19
|
+
Artistic 2.0
|
20
|
+
|
21
|
+
= Copyright
|
22
|
+
(C) 2009 Lorenzo Boccetti, The PVPGN Team, All Rights Reserved .
|
23
|
+
|
24
|
+
= Warranty
|
25
|
+
This package is provided "as is" and without any express or
|
26
|
+
implied warranties, including, without limitation, the implied
|
27
|
+
warranties of merchantability and fitness for a particular purpose.
|
28
|
+
|
29
|
+
= Authors
|
30
|
+
Lorenzo Boccetti
|
data/ext/extconf.rb
ADDED
data/ext/pvpgn.cpp
ADDED
@@ -0,0 +1,206 @@
|
|
1
|
+
#define PVPGN_TWILIGHT_VERSION "0.0.6"
|
2
|
+
|
3
|
+
#ifdef __TEST__
|
4
|
+
#include <iostream>
|
5
|
+
#else
|
6
|
+
#include "ruby.h"
|
7
|
+
#endif
|
8
|
+
|
9
|
+
typedef unsigned int t_uint32;
|
10
|
+
typedef signed int t_sint32;
|
11
|
+
|
12
|
+
#define ROTL(x,n,w) (((x)<<((n)&(w-1))) | ((x)>>(((-(n))&(w-1)))))
|
13
|
+
|
14
|
+
#define ROTL32(x,n) ROTL(x,n,32)
|
15
|
+
#define ROTL16(x,n) ROTL(x,n,16)
|
16
|
+
|
17
|
+
static void PVPGN_Hash(t_uint32* pHash, t_uint32* pTemp)
|
18
|
+
{
|
19
|
+
t_uint32 i;
|
20
|
+
|
21
|
+
for(i = 0; i < 64; i++)
|
22
|
+
pTemp[i + 16] = ROTL32(1,pTemp[i] ^ pTemp[i + 8] ^ pTemp[i + 2] ^ pTemp[i + 13]);
|
23
|
+
|
24
|
+
t_uint32 a = pHash[0];
|
25
|
+
t_uint32 b = pHash[1];
|
26
|
+
t_uint32 c = pHash[2];
|
27
|
+
t_uint32 d = pHash[3];
|
28
|
+
t_uint32 e = pHash[4];
|
29
|
+
t_uint32 g;
|
30
|
+
|
31
|
+
for(i = 0; i < 20; i++)
|
32
|
+
{
|
33
|
+
g = pTemp[i] + ROTL32(a,5) + e + ((b & c) | (~b & d)) + 0x5a827999;
|
34
|
+
e = d;
|
35
|
+
d = c;
|
36
|
+
c = ROTL32(b,30);
|
37
|
+
b = a;
|
38
|
+
a = g;
|
39
|
+
}
|
40
|
+
|
41
|
+
for(; i < 40; i++)
|
42
|
+
{
|
43
|
+
g = (d ^ c ^ b) + e + ROTL32(g,5) + pTemp[i] + 0x6ed9eba1;
|
44
|
+
e = d;
|
45
|
+
d = c;
|
46
|
+
c = ROTL32(b,30);
|
47
|
+
b = a;
|
48
|
+
a = g;
|
49
|
+
}
|
50
|
+
|
51
|
+
for (; i < 60; i++)
|
52
|
+
{
|
53
|
+
g = pTemp[i] + ROTL32(g,5) + e + ((c & b) | (d & c) | (d & b)) - 0x70e44324;
|
54
|
+
e = d;
|
55
|
+
d = c;
|
56
|
+
c = ROTL32(b,30);
|
57
|
+
b = a;
|
58
|
+
a = g;
|
59
|
+
}
|
60
|
+
|
61
|
+
for (; i < 80; i++)
|
62
|
+
{
|
63
|
+
g = (d ^ c ^ b) + e + ROTL32(g,5) + pTemp[i] - 0x359d3e2a;
|
64
|
+
e = d;
|
65
|
+
d = c;
|
66
|
+
c = ROTL32(b,30);
|
67
|
+
b = a;
|
68
|
+
a = g;
|
69
|
+
}
|
70
|
+
|
71
|
+
pHash[0] += g;
|
72
|
+
pHash[1] += b;
|
73
|
+
pHash[2] += c;
|
74
|
+
pHash[3] += d;
|
75
|
+
pHash[4] += e;
|
76
|
+
}
|
77
|
+
|
78
|
+
static void PVPGN_Set16(t_uint32* pDest, const unsigned char* pSource, t_sint32 nSize)
|
79
|
+
{
|
80
|
+
if(pDest == NULL || pSource == NULL || nSize < 0)
|
81
|
+
return;
|
82
|
+
|
83
|
+
t_uint32 i, dwPos;
|
84
|
+
for(dwPos = 0, i = 0; i < 16; i++)
|
85
|
+
{
|
86
|
+
pDest[i] = 0;
|
87
|
+
if(dwPos < nSize)
|
88
|
+
pDest[i] |= ((t_uint32)pSource[dwPos]);
|
89
|
+
|
90
|
+
dwPos++;
|
91
|
+
if(dwPos < nSize)
|
92
|
+
pDest[i] |= ((t_uint32)pSource[dwPos]) << 8;
|
93
|
+
|
94
|
+
dwPos++;
|
95
|
+
if(dwPos < nSize)
|
96
|
+
pDest[i] |= ((t_uint32)pSource[dwPos]) << 16;
|
97
|
+
|
98
|
+
dwPos++;
|
99
|
+
if(dwPos < nSize)
|
100
|
+
pDest[i] |= ((t_uint32)pSource[dwPos]) << 24;
|
101
|
+
|
102
|
+
dwPos++;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
static void UTILITY_ToLower(char* pString)
|
107
|
+
{
|
108
|
+
if(pString == NULL)
|
109
|
+
return;
|
110
|
+
|
111
|
+
char nChar = 0;
|
112
|
+
while((nChar = *pString))
|
113
|
+
*pString++ = ((nChar < 'A' || nChar > 'Z') ? nChar : (nChar + 0x20));
|
114
|
+
}
|
115
|
+
|
116
|
+
static void UTILITY_HexToText(char* pBuffer, t_uint32 dwHex, t_uint32 bUpper = 0)
|
117
|
+
{
|
118
|
+
if(pBuffer == NULL)
|
119
|
+
return;
|
120
|
+
|
121
|
+
static const char szHex[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
|
122
|
+
static const char szHexU[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
123
|
+
int i;
|
124
|
+
if(!bUpper)
|
125
|
+
{
|
126
|
+
for(i = 7; i > -1; i--)
|
127
|
+
{
|
128
|
+
int nChar = dwHex % 16;
|
129
|
+
dwHex >>= 4;
|
130
|
+
pBuffer[i] = szHex[nChar];
|
131
|
+
}
|
132
|
+
}
|
133
|
+
else
|
134
|
+
{
|
135
|
+
for(i = 7; i > -1; i--)
|
136
|
+
{
|
137
|
+
int nChar = dwHex % 16;
|
138
|
+
dwHex >>= 4;
|
139
|
+
pBuffer[i] = szHexU[nChar];
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
static char* PVPGN_CreateHash(char* pHash, t_sint32 nSize)
|
145
|
+
{
|
146
|
+
if(pHash == NULL || nSize < 1)
|
147
|
+
return NULL;
|
148
|
+
|
149
|
+
t_uint32 dwLength = 0, i;
|
150
|
+
unsigned char* pData = (unsigned char*)pHash;
|
151
|
+
char pHashOut[41];
|
152
|
+
t_uint32 dwHash[5] = {0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0};
|
153
|
+
t_uint32 dwTemp[80];
|
154
|
+
|
155
|
+
pHashOut[40] = 0;
|
156
|
+
UTILITY_ToLower(pHash);
|
157
|
+
while(nSize > 0)
|
158
|
+
{
|
159
|
+
dwLength = (nSize > 64) ? 64 : nSize;
|
160
|
+
PVPGN_Set16(dwTemp,pData,dwLength);
|
161
|
+
PVPGN_Hash(dwHash,dwTemp);
|
162
|
+
nSize -= dwLength;
|
163
|
+
pData += dwLength;
|
164
|
+
}
|
165
|
+
|
166
|
+
for(i = 0; i < 5; i++)
|
167
|
+
UTILITY_HexToText(&pHashOut[i * 8],dwHash[i]);
|
168
|
+
|
169
|
+
return pHashOut;
|
170
|
+
}
|
171
|
+
#ifdef __TEST__
|
172
|
+
int main(int argc, char *argv[])
|
173
|
+
{
|
174
|
+
std::string sInput;
|
175
|
+
std::cout << "Please Enter Password: ";
|
176
|
+
std::cin >> sInput;
|
177
|
+
std::cout << "Hash: " << PVPGN_CreateHash((char*)sInput.c_str(),sInput.size()) << std::endl;
|
178
|
+
system("PAUSE");
|
179
|
+
return 0;
|
180
|
+
}
|
181
|
+
#else
|
182
|
+
/*
|
183
|
+
* call-seq:
|
184
|
+
* PVPGN.BNHash(string_to_hash)
|
185
|
+
*
|
186
|
+
* Creates the PVPGN hash for the give string, it is automatically
|
187
|
+
* converted to a lower case string, the input is also automatically
|
188
|
+
* converted to lower case
|
189
|
+
*/
|
190
|
+
static VALUE __cdecl RUBY_BNHash(int argc, VALUE* argv, VALUE klass)
|
191
|
+
{
|
192
|
+
VALUE vPassword;
|
193
|
+
if(argc != 1)
|
194
|
+
rb_raise(rb_eRuntimeError,"Invalid Amount of Arguments");
|
195
|
+
|
196
|
+
vPassword = argv[0];
|
197
|
+
char* szPass = StringValuePtr(vPassword);
|
198
|
+
return rb_str_new2(PVPGN_CreateHash(szPass,strlen(szPass)));
|
199
|
+
}
|
200
|
+
|
201
|
+
void Init_pvpgn()
|
202
|
+
{
|
203
|
+
static VALUE mPVPGN = rb_define_module("PVPGN");
|
204
|
+
rb_define_module_function(mPVPGN,"BNHash",(VALUE (*)(...))RUBY_BNHash,-1);
|
205
|
+
}
|
206
|
+
#endif
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{pvpgn-twilight}
|
3
|
+
s.version = "0.0.7"
|
4
|
+
s.date = %q{2009-09-30}
|
5
|
+
s.authors = ["Lorenzo Boccetti"]
|
6
|
+
s.email = %q{necrolis@gamil.com}
|
7
|
+
s.summary = %q{A ruby interface for Twilight PVPGN}
|
8
|
+
s.homepage = %q{http://www.war3.co.za}
|
9
|
+
s.description = %q{PVPGN-Twilight allows ruby scripts to communicate with pvpgn, while providing faster varients of certain functions, like hashing}
|
10
|
+
s.files = ["pvpgn-twilight.gemspec","ext/pvpgn.cpp","examples/pvpgn_test.rb","ext/extconf.rb","Changes","docs/pvpgn-twilight.txt","pvpgn-twilight.gemspec"]
|
11
|
+
s.extensions << 'ext/extconf.rb'
|
12
|
+
s.has_rdoc = true
|
13
|
+
s.extra_rdoc_files = ["Changes","ext/pvpgn.cpp","docs/pvpgn-twilight.txt"]
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pvpgn-twilight
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lorenzo Boccetti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-30 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: PVPGN-Twilight allows ruby scripts to communicate with pvpgn, while providing faster varients of certain functions, like hashing
|
17
|
+
email: necrolis@gamil.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- Changes
|
24
|
+
- ext/pvpgn.cpp
|
25
|
+
- docs/pvpgn-twilight.txt
|
26
|
+
files:
|
27
|
+
- pvpgn-twilight.gemspec
|
28
|
+
- ext/pvpgn.cpp
|
29
|
+
- examples/pvpgn_test.rb
|
30
|
+
- ext/extconf.rb
|
31
|
+
- Changes
|
32
|
+
- docs/pvpgn-twilight.txt
|
33
|
+
has_rdoc: true
|
34
|
+
homepage: http://www.war3.co.za
|
35
|
+
licenses: []
|
36
|
+
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.3.5
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: A ruby interface for Twilight PVPGN
|
61
|
+
test_files: []
|
62
|
+
|