├── LICENSE ├── README ├── phAnalyzer.sln └── phAnalyzer ├── PH.ico ├── PH.png ├── Stream ├── stream_utility.cpp └── stream_utility.h ├── analyzer.cpp ├── analyzer.h ├── analyzer.qrc ├── analyzer.ui ├── injection.cpp ├── injection.h ├── injection.ui ├── main.cpp ├── phAnalyzer.rc ├── phAnalyzer.vcxproj ├── phAnalyzer.vcxproj.filters └── resource.h /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | phAnalyzer - Silkroad Packet Analyzer 2 | 3 | Requirements: 4 | Visual Studio 2010 5 | Qt 6 | 7 | 8 | -------------------------------------------------------------------------------- /phAnalyzer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "phAnalyzer", "phAnalyzer\phAnalyzer.vcxproj", "{DC6372E9-682D-4046-9662-62423CDEC055}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {DC6372E9-682D-4046-9662-62423CDEC055}.Debug|Win32.ActiveCfg = Release|Win32 13 | {DC6372E9-682D-4046-9662-62423CDEC055}.Debug|Win32.Build.0 = Release|Win32 14 | {DC6372E9-682D-4046-9662-62423CDEC055}.Release|Win32.ActiveCfg = Release|Win32 15 | {DC6372E9-682D-4046-9662-62423CDEC055}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /phAnalyzer/PH.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectHax/phAnalyzer/a33869dabbfe6d3427fba117f6dcb283e3d9c51f/phAnalyzer/PH.ico -------------------------------------------------------------------------------- /phAnalyzer/PH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectHax/phAnalyzer/a33869dabbfe6d3427fba117f6dcb283e3d9c51f/phAnalyzer/PH.png -------------------------------------------------------------------------------- /phAnalyzer/Stream/stream_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "stream_utility.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | //----------------------------------------------------------------------------- 8 | 9 | StreamUtility::StreamUtility() 10 | : m_stream( m_stream_internal ) 11 | { 12 | Clear(); 13 | } 14 | 15 | StreamUtility::StreamUtility( std::vector< uint8_t > & stream ) 16 | : m_stream( stream ) 17 | { 18 | m_read_index = 0; 19 | m_read_error = false; 20 | m_write_error = 0; 21 | } 22 | 23 | StreamUtility::StreamUtility( const void * const buffer, int32_t size ) 24 | : m_stream( m_stream_internal ) 25 | { 26 | Clear(); 27 | Overwrite< uint8_t >( 0, reinterpret_cast< const uint8_t * >( buffer ), size ); 28 | } 29 | 30 | StreamUtility::StreamUtility( const StreamUtility & rhs ) 31 | : m_stream( m_stream_internal ), m_read_index ( rhs.m_read_index ), m_read_error( rhs.m_read_error ) 32 | { 33 | m_stream = rhs.m_stream; 34 | } 35 | 36 | StreamUtility::~StreamUtility() 37 | { 38 | } 39 | 40 | StreamUtility & StreamUtility::operator =( const StreamUtility & rhs ) 41 | { 42 | if( &rhs != this ) 43 | { 44 | m_stream = rhs.m_stream; 45 | m_read_index = rhs.m_read_index; 46 | m_read_error = rhs.m_read_error; 47 | m_write_error = rhs.m_read_error; 48 | } 49 | return *this; 50 | } 51 | 52 | void StreamUtility::Clear() 53 | { 54 | m_stream.clear(); 55 | m_read_index = 0; 56 | m_read_error = false; 57 | m_write_error = false; 58 | } 59 | 60 | bool StreamUtility::WasWriteError() 61 | { 62 | return m_write_error; 63 | } 64 | 65 | bool StreamUtility::WasReadError() 66 | { 67 | return m_read_error; 68 | } 69 | 70 | void StreamUtility::ClearReadError() 71 | { 72 | m_read_error = false; 73 | } 74 | 75 | void StreamUtility::ClearWriteError() 76 | { 77 | m_write_error = false; 78 | } 79 | 80 | const std::vector< uint8_t > & StreamUtility::GetStreamVector() 81 | { 82 | return m_stream; 83 | } 84 | 85 | const uint8_t * StreamUtility::GetStreamPtr() 86 | { 87 | return m_stream.empty() ? 0 : &m_stream[0]; 88 | } 89 | 90 | int32_t StreamUtility::GetStreamSize() 91 | { 92 | return static_cast< int32_t >( m_stream.size() ); 93 | } 94 | 95 | int32_t StreamUtility::GetWriteIndex() 96 | { 97 | return static_cast< int32_t >( m_stream.size() ) - 1; 98 | } 99 | 100 | const uint8_t * StreamUtility::GetReadStreamPtr() 101 | { 102 | if( m_read_index == 0 || m_read_index >= static_cast< int32_t >( m_stream.size() ) ) 103 | { 104 | return NULL; 105 | } 106 | return &m_stream[m_read_index]; 107 | } 108 | 109 | int32_t StreamUtility::GetReadStreamSize() 110 | { 111 | if( m_read_index >= static_cast< int32_t >( m_stream.size() ) ) 112 | { 113 | return 0; 114 | } 115 | return static_cast< int32_t >( m_stream.size() ) - m_read_index; 116 | } 117 | 118 | int32_t StreamUtility::GetReadIndex() 119 | { 120 | return m_read_index; 121 | } 122 | 123 | bool StreamUtility::SeekRead( int32_t index, SeekDirection dir ) 124 | { 125 | int32_t old_read_index = m_read_index; 126 | if( dir == Seek_Set ) 127 | { 128 | m_read_index = index; 129 | } 130 | else if( dir == Seek_Forward ) 131 | { 132 | m_read_index += index; 133 | } 134 | else if( dir == Seek_Backward ) 135 | { 136 | m_read_index -= index; 137 | } 138 | else if( dir == Seek_End ) 139 | { 140 | m_read_index = static_cast< int32_t >( m_stream.size() ) - 1; 141 | m_read_index -= index; 142 | } 143 | if( m_read_index > static_cast< int32_t >( m_stream.size() ) ) 144 | { 145 | m_read_index = old_read_index; 146 | return false; 147 | } 148 | return true; 149 | } 150 | 151 | int32_t StreamUtility::Delete( int32_t index, int32_t count ) 152 | { 153 | int32_t delcount = 0; 154 | if( index < static_cast< int32_t >( m_stream.size() ) ) 155 | { 156 | delcount = static_cast< int32_t >( m_stream.size() ) - index; 157 | if( delcount > count ) 158 | { 159 | delcount = count; 160 | } 161 | } 162 | if( delcount ) 163 | { 164 | m_stream.erase( m_stream.begin() + index, m_stream.begin() + index + delcount ); 165 | if( m_read_index > static_cast< int32_t >( m_stream.size() ) ) 166 | { 167 | m_read_index = static_cast< int32_t >( m_stream.size() ); 168 | } 169 | } 170 | return delcount; 171 | } 172 | 173 | std::string StreamUtility::Read_Ascii( int32_t count ) 174 | { 175 | if( count == 0 ) 176 | { 177 | return ""; 178 | } 179 | std::string str; 180 | str.resize( count ); 181 | Read< char >( &str[0], count ); 182 | if( m_read_error ) 183 | { 184 | str.clear(); 185 | } 186 | return str; 187 | } 188 | 189 | std::wstring StreamUtility::Read_AsciiToUnicode( int32_t count ) 190 | { 191 | if( count == 0 ) 192 | { 193 | return L""; 194 | } 195 | std::string str; 196 | str.resize( count ); 197 | Read< char >( &str[0], count ); 198 | if( m_read_error ) 199 | { 200 | return L""; 201 | } 202 | int32_t converted = static_cast< int32_t >( mbstowcs( NULL, str.c_str(), count ) ); 203 | if( converted == 0 || ( converted - 1 ) != count ) 204 | { 205 | m_read_error = true; 206 | return L""; 207 | } 208 | std::wstring wcsStr; 209 | wcsStr.resize( converted ); 210 | mbstowcs( &wcsStr[0], str.c_str(), count ); 211 | wcsStr.erase( wcsStr.end() - 1 ); // remove extra null terminator 212 | return wcsStr; 213 | } 214 | 215 | std::wstring StreamUtility::Read_Unicode( int32_t count ) 216 | { 217 | if( count == 0 ) 218 | { 219 | return L""; 220 | } 221 | std::wstring str; 222 | str.resize( count ); 223 | Read< wchar_t >( &str[0], count ); 224 | if( m_read_error ) 225 | { 226 | str.clear(); 227 | } 228 | return str; 229 | } 230 | 231 | std::string StreamUtility::Read_UnicodeToAscii( int32_t count ) 232 | { 233 | if( count == 0 ) 234 | { 235 | return ""; 236 | } 237 | std::wstring str; 238 | str.resize( count ); 239 | Read< wchar_t >( &str[0], count ); 240 | if( m_read_error ) 241 | { 242 | return ""; 243 | } 244 | int32_t converted = static_cast< int32_t >( wcstombs( NULL, str.c_str(), count ) ); 245 | if( converted == 0 || ( converted - 1 ) != count ) 246 | { 247 | m_read_error = true; 248 | return ""; 249 | } 250 | std::string mbsStr; 251 | mbsStr.resize( converted ); 252 | wcstombs( &mbsStr[0], str.c_str(), count ); 253 | mbsStr.erase( mbsStr.end() - 1 ); // remove extra null terminator 254 | return mbsStr; 255 | } 256 | 257 | void StreamUtility::Write_Ascii( const std::string & mbs_text ) 258 | { 259 | Write_Ascii( mbs_text.c_str(), static_cast< int32_t >( mbs_text.size() ) ); 260 | } 261 | 262 | void StreamUtility::Write_AsciiToUnicode( const std::string & mbs_text ) 263 | { 264 | Write_AsciiToUnicode( mbs_text.c_str(), static_cast< int32_t >( mbs_text.size() ) ); 265 | } 266 | 267 | void StreamUtility::Write_UnicodeToAscii( const std::wstring & wcs_text ) 268 | { 269 | Write_UnicodeToAscii( wcs_text.c_str(), static_cast< int32_t >( wcs_text.size() ) ); 270 | } 271 | 272 | void StreamUtility::Write_Unicode( const std::wstring & wcs_text ) 273 | { 274 | Write_Unicode( wcs_text.c_str(), static_cast< int32_t >( wcs_text.size() ) ); 275 | } 276 | 277 | void StreamUtility::Write_Ascii( const char * mbs_text, int32_t count ) 278 | { 279 | Write< char >( mbs_text, count ); 280 | } 281 | 282 | void StreamUtility::Write_AsciiToUnicode( const char * mbs_text, int32_t count ) 283 | { 284 | if( count == 0 ) 285 | { 286 | return; 287 | } 288 | int32_t converted = static_cast< int32_t >( mbstowcs( NULL, mbs_text, count ) ); 289 | if( converted == 0 || ( converted - 1 ) != count ) 290 | { 291 | m_write_error = true; 292 | return; 293 | } 294 | std::wstring wcsStr; 295 | wcsStr.resize( converted ); 296 | mbstowcs( &wcsStr[0], mbs_text, count ); 297 | Write_Unicode( wcsStr.c_str(), converted - 1 ); 298 | } 299 | 300 | void StreamUtility::Write_UnicodeToAscii( const wchar_t * wcs_text, int32_t count ) 301 | { 302 | if( count == 0 ) 303 | { 304 | return; 305 | } 306 | int32_t converted = static_cast< int32_t >( wcstombs( NULL, wcs_text, count ) ); 307 | if( converted == 0 || ( converted - 1 ) != count ) 308 | { 309 | m_write_error = true; 310 | return; 311 | } 312 | std::string mbsStr; 313 | mbsStr.resize( converted ); 314 | wcstombs( &mbsStr[0], wcs_text, count ); 315 | Write_Ascii( mbsStr.c_str(), converted - 1 ); 316 | } 317 | 318 | void StreamUtility::Write_Unicode( const wchar_t * wcs_text, int32_t count ) 319 | { 320 | Write< wchar_t >( wcs_text, count ); 321 | } 322 | 323 | StreamUtility StreamUtility::Extract( int32_t index, int32_t count ) 324 | { 325 | StreamUtility result; 326 | if( count == -1 ) 327 | { 328 | count = static_cast< int32_t >( m_stream.size() ) - index; 329 | } 330 | if( count && index + count <= static_cast< int32_t >( m_stream.size() ) ) 331 | { 332 | result.Write( &m_stream[index], count ); 333 | } 334 | return result; 335 | } 336 | 337 | //----------------------------------------------------------------------------- 338 | 339 | std::string DumpToString( StreamUtility & stream_utility ) 340 | { 341 | return DumpToString( stream_utility.GetStreamVector() ); 342 | } 343 | 344 | std::string DumpToString( const std::vector< uint8_t > & buffer ) 345 | { 346 | return DumpToString( buffer.empty() ? 0 : &buffer[0], static_cast< int32_t >( buffer.size() ) ); 347 | } 348 | 349 | std::string DumpToString( const void * stream, int32_t size ) 350 | { 351 | std::stringstream ss; 352 | const unsigned char * buffer = reinterpret_cast< const unsigned char * >( stream ); 353 | int fields[16]; 354 | int32_t index = 0; 355 | int32_t cur = 0; 356 | int32_t total = size; 357 | if( total == 0 || total % 16 ) 358 | { 359 | total += ( 16 - ( total % 16 ) ); 360 | } 361 | for( int32_t x = 0; x < total; ++x ) 362 | { 363 | fields[ index++ ] = cur < size ? buffer[ x ] : 0; 364 | ++cur; 365 | if( index == 16 ) 366 | { 367 | for( int32_t y = 0; y < 16; ++y ) 368 | { 369 | if( cur - 16 + y < size ) 370 | { 371 | ss << std::hex << std::setfill( '0' ) << std::setw( 2 ) << fields[ y ] << " "; 372 | } 373 | else 374 | { 375 | ss << " "; 376 | } 377 | } 378 | ss << " "; 379 | for( int32_t y = 0; y < 16; ++y ) 380 | { 381 | if( cur - 16 + y < size ) 382 | { 383 | int ch = fields[ y ]; 384 | if( isprint( ch ) && !isspace( ch ) ) 385 | { 386 | ss << (char)ch; 387 | } 388 | else 389 | { 390 | ss << "."; 391 | } 392 | } 393 | else 394 | { 395 | ss << "."; 396 | } 397 | } 398 | ss << std::endl; 399 | index = 0; 400 | } 401 | } 402 | std::string final = ss.str(); 403 | return final; 404 | } 405 | 406 | //----------------------------------------------------------------------------- 407 | -------------------------------------------------------------------------------- /phAnalyzer/Stream/stream_utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef STREAM_UTILITY_H 4 | #define STREAM_UTILITY_H 5 | 6 | //----------------------------------------------------------------------------- 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | //----------------------------------------------------------------------------- 15 | 16 | enum SeekDirection 17 | { 18 | Seek_Set, 19 | Seek_Forward, 20 | Seek_Backward, 21 | Seek_End 22 | }; 23 | 24 | //----------------------------------------------------------------------------- 25 | 26 | class StreamUtility 27 | { 28 | private: 29 | std::vector< uint8_t > & m_stream; 30 | std::vector< uint8_t > m_stream_internal; 31 | int32_t m_read_index; 32 | bool m_read_error; 33 | bool m_write_error; 34 | 35 | public: 36 | StreamUtility(); 37 | StreamUtility( std::vector< uint8_t > & stream ); 38 | StreamUtility( const void * const buffer, int32_t size ); 39 | StreamUtility( const StreamUtility & rhs ); 40 | ~StreamUtility(); 41 | StreamUtility & operator =( const StreamUtility & rhs ); 42 | void Clear(); 43 | bool WasWriteError(); 44 | bool WasReadError(); 45 | void ClearReadError(); 46 | void ClearWriteError(); 47 | const std::vector< uint8_t > & GetStreamVector(); 48 | const uint8_t * GetStreamPtr(); 49 | int32_t GetStreamSize(); 50 | int32_t GetWriteIndex(); 51 | const uint8_t * GetReadStreamPtr(); 52 | int32_t GetReadStreamSize(); 53 | int32_t GetReadIndex(); 54 | bool SeekRead( int32_t index, SeekDirection dir ); 55 | int32_t Delete( int32_t index, int32_t count ); 56 | std::string Read_Ascii( int32_t count ); 57 | std::wstring Read_AsciiToUnicode( int32_t count ); 58 | std::wstring Read_Unicode( int32_t count ); 59 | std::string Read_UnicodeToAscii( int32_t count ); 60 | void Write_Ascii( const std::string & mbs_text ); 61 | void Write_AsciiToUnicode( const std::string & mbs_text ); 62 | void Write_UnicodeToAscii( const std::wstring & wcs_text ); 63 | void Write_Unicode( const std::wstring & wcs_text ); 64 | void Write_Ascii( const char * mbs_text, int32_t count ); 65 | void Write_AsciiToUnicode( const char * mbs_text, int32_t count ); 66 | void Write_UnicodeToAscii( const wchar_t * wcs_text, int32_t count ); 67 | void Write_Unicode( const wchar_t * wcs_text, int32_t count ); 68 | StreamUtility Extract( int32_t index, int32_t count ); 69 | 70 | template 71 | type Read( bool peek = false ) 72 | { 73 | type val = 0; 74 | Read< type >( &val, 1, peek ); 75 | return val; 76 | } 77 | 78 | template 79 | void Read( type * out, int32_t count, bool peek = false ) 80 | { 81 | if( count == 0 ) 82 | { 83 | return; 84 | } 85 | if( m_read_error || m_read_index + ( count * sizeof( type ) ) > static_cast< int32_t >( m_stream.size() ) ) 86 | { 87 | m_read_error = true; 88 | } 89 | else 90 | { 91 | memcpy( out, &m_stream[m_read_index], ( count * sizeof( type ) ) ); 92 | if( !peek ) 93 | { 94 | m_read_index += ( count * sizeof( type ) ); 95 | } 96 | } 97 | } 98 | 99 | template 100 | void Write( const std::vector< type > & val ) 101 | { 102 | Write< type >( val.empty() ? 0 : &val[0], static_cast< int32_t >( val.size() ) ); 103 | } 104 | 105 | template 106 | void Write( type val ) 107 | { 108 | Write< type >( &val, 1 ); 109 | } 110 | 111 | template 112 | void Write( const type * const input, int32_t count ) 113 | { 114 | if( count ) 115 | { 116 | std::copy( (uint8_t *)input, (count * sizeof(type)) + (uint8_t *)input, std::back_inserter( m_stream ) ); 117 | } 118 | } 119 | 120 | template 121 | void Insert( int32_t index, const std::vector< type > & val ) 122 | { 123 | Insert< type >( index, val.empty() ? 0 : &val[0], static_cast< int32_t >( val.size() ) ); 124 | } 125 | 126 | template 127 | void Insert( int32_t index, type val ) 128 | { 129 | Insert< type >( index, &val, 1 ); 130 | } 131 | 132 | template 133 | void Insert( int32_t index, const type * const input, int32_t count ) 134 | { 135 | if( index >= static_cast< int32_t >( m_stream.size() ) ) 136 | { 137 | m_stream.resize( static_cast< int32_t >( m_stream.size() ) + ( sizeof( type ) * count ) ); 138 | } 139 | else 140 | { 141 | m_stream.resize( m_stream.size() + ( sizeof( type ) * count ) ); 142 | memmove( &m_stream[index + sizeof( type ) * count], &m_stream[index], static_cast< int32_t >( m_stream.size() ) - index - sizeof( type ) * count ); 143 | } 144 | memcpy( &m_stream[index], input, ( count * sizeof( type ) ) ); 145 | } 146 | 147 | template 148 | void Overwrite( int32_t index, const std::vector< type > & val ) 149 | { 150 | Overwrite< type >( index, val.empty() ? 0 : &val[0], static_cast< int32_t >( val.size() ) ); 151 | } 152 | 153 | template 154 | void Overwrite( int32_t index, type val ) 155 | { 156 | Overwrite< type >( index, &val, 1 ); 157 | } 158 | 159 | template 160 | void Overwrite( int32_t index, const type * const input, int32_t count ) 161 | { 162 | if( static_cast< int32_t >( m_stream.size() ) < index + ( count * sizeof( type ) ) ) 163 | { 164 | m_stream.resize( index + ( count * sizeof( type ) ) ); 165 | } 166 | memcpy( &m_stream[index], input, count * sizeof( type ) ); 167 | } 168 | 169 | template 170 | void Fill( int32_t index, type value, int32_t count ) 171 | { 172 | if( static_cast< int32_t >( m_stream.size() ) < index + ( sizeof( type ) * count ) ) 173 | { 174 | m_stream.resize( index + ( sizeof( type ) * count ) ); 175 | } 176 | type * stream = reinterpret_cast< type * >( &m_stream[index] ); 177 | for( int32_t x = 0; x < count; ++x ) 178 | { 179 | stream[x] = value; 180 | } 181 | } 182 | }; 183 | 184 | //----------------------------------------------------------------------------- 185 | 186 | std::string DumpToString( StreamUtility & stream_utility ); 187 | std::string DumpToString( const std::vector< uint8_t > & buffer ); 188 | std::string DumpToString( const void * stream, int32_t size ); 189 | 190 | //----------------------------------------------------------------------------- 191 | 192 | #endif 193 | -------------------------------------------------------------------------------- /phAnalyzer/analyzer.cpp: -------------------------------------------------------------------------------- 1 | #include "analyzer.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | //Constructor 9 | phAnalyzer::phAnalyzer(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags), inj(0) 10 | { 11 | //Sets up the UI 12 | ui.setupUi(this); 13 | 14 | //Get absolute path to application 15 | QString path = QApplication::applicationFilePath(); 16 | path = path.replace(path.mid(path.lastIndexOf("/")), ""); 17 | 18 | //Load settings 19 | QSettings settings(path + "/phAnalyzer.ini", QSettings::IniFormat); 20 | HOST = settings.value("phAnalyzer/Host").toString(); 21 | PORT = settings.value("phAnalyzer/Port").toUInt(); 22 | 23 | //Make sure the host/IP is not empty 24 | if(HOST.isEmpty()) 25 | { 26 | //Set default IP 27 | settings.setValue("phAnalyzer/Host", "127.0.0.1"); 28 | HOST = "127.0.0.1"; 29 | } 30 | 31 | //Make sure the port is not null 32 | if(PORT == 0) 33 | { 34 | //Set default port 35 | settings.setValue("phAnalyzer/Port", 22580); 36 | PORT = 22580; 37 | } 38 | 39 | //Connect file menu actions 40 | connect(ui.actionSave, SIGNAL(triggered()), this, SLOT(Save())); 41 | connect(ui.actionInject, SIGNAL(triggered()), this, SLOT(Inject())); 42 | connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); 43 | 44 | //Connect right click menu for removing opcodes 45 | connect(ui.lstIgnore, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(RemoveOpcodeMenu(const QPoint &))); 46 | connect(ui.lstListen, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(RemoveOpcodeMenu(const QPoint &))); 47 | 48 | //New socket 49 | socket = new QTcpSocket(this); 50 | 51 | //Create the injection UI 52 | inj = new injection(0, socket); 53 | 54 | //Setup the connection slots 55 | connect(socket, SIGNAL(connected()), this, SLOT(Connected())); 56 | connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(SocketState(QAbstractSocket::SocketState))); 57 | connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead())); 58 | 59 | //Connect 60 | socket->connectToHost(HOST, PORT); 61 | } 62 | 63 | //Destructor 64 | phAnalyzer::~phAnalyzer() 65 | { 66 | //Cleanup 67 | socket->close(); 68 | delete inj; 69 | } 70 | 71 | //Processes close events 72 | void phAnalyzer::closeEvent(QCloseEvent* event) 73 | { 74 | //Packet injector window might be active so close it, otherwise it will get stuck while attempting to exit 75 | inj->close(); 76 | } 77 | 78 | //Adds an opcode to the ignore list when the enter key is pressed 79 | void phAnalyzer::AddIgnoreOpcode() 80 | { 81 | QString text = ui.txtIgnore->text().toUpper(); 82 | 83 | //Length check 84 | if(text.length() == 4) 85 | { 86 | //Clear text box 87 | ui.txtIgnore->clear(); 88 | 89 | //See if the opcode is already in the list 90 | for(int x = 0; x < ui.lstIgnore->count(); ++x) 91 | { 92 | if(ui.lstIgnore->item(x)->text() == text) 93 | return; 94 | } 95 | 96 | //Add the opcode to the ignore list 97 | ui.lstIgnore->addItem(text); 98 | } 99 | else 100 | { 101 | QMessageBox::warning(this, "Error", "Opcode length must be 4."); 102 | } 103 | } 104 | 105 | //Adds an opcode to the listen list when the enter key is pressed 106 | void phAnalyzer::AddListenOpcode() 107 | { 108 | QString text = ui.txtListen->text().toUpper(); 109 | 110 | //Length check 111 | if(text.length() == 4) 112 | { 113 | //Clear text box 114 | ui.txtListen->clear(); 115 | 116 | //See if the opcode is already in the list 117 | for(int x = 0; x < ui.lstListen->count(); ++x) 118 | { 119 | if(ui.lstListen->item(x)->text() == text) 120 | return; 121 | } 122 | 123 | //Add the opcode to the listen list 124 | ui.lstListen->addItem(text); 125 | } 126 | else 127 | { 128 | //Invalid opcode length 129 | QMessageBox::warning(this, "Error", "Opcode length must be 4."); 130 | } 131 | } 132 | 133 | //Socket connected 134 | void phAnalyzer::Connected() 135 | { 136 | //Change the window title 137 | setWindowTitle("phAnalyzer - ProjectHax.com - Connected"); 138 | 139 | //Start reading data 140 | socket->waitForReadyRead(2); 141 | } 142 | 143 | //Socket state changed 144 | void phAnalyzer::SocketState(QAbstractSocket::SocketState state) 145 | { 146 | if(state == QAbstractSocket::UnconnectedState) 147 | { 148 | //Change the window title 149 | setWindowTitle("phAnalyzer - ProjectHax.com - Disconnected"); 150 | 151 | //Attempt to reconnect 152 | socket->connectToHost(HOST, PORT); 153 | } 154 | } 155 | 156 | //Read data 157 | void phAnalyzer::readyRead() 158 | { 159 | data.resize(socket->bytesAvailable()); 160 | uint64_t count = socket->read(&data[0], socket->bytesAvailable()); 161 | 162 | //Write the received data to the end of the stream 163 | pending_stream.Write(&data[0], count); 164 | 165 | //Total size of stream 166 | int32_t total_bytes = pending_stream.GetStreamSize(); 167 | 168 | //Make sure there are enough bytes for the packet size to be read 169 | while(total_bytes > 2) 170 | { 171 | //Peek the packet size 172 | uint16_t required_size = pending_stream.Read(true) + 6; 173 | 174 | //See if there are enough bytes for this packet 175 | if(required_size <= total_bytes) 176 | { 177 | StreamUtility r(pending_stream); 178 | 179 | //Remove this packet from the stream 180 | pending_stream.Delete(0, required_size); 181 | pending_stream.SeekRead(0, Seek_Set); 182 | total_bytes -= required_size; 183 | 184 | //Paused? 185 | if(ui.chkPause->isChecked()) 186 | continue; 187 | 188 | //Extract packet header information 189 | uint16_t size = r.Read(); 190 | uint16_t opcode = r.Read(); 191 | uint8_t direction = r.Read(); 192 | uint8_t encrypted = r.Read(); 193 | 194 | //Remove the header 195 | r.Delete(0, 6); 196 | r.SeekRead(0, Seek_Set); 197 | 198 | //Player ID 199 | if(opcode == 0x3020) 200 | { 201 | //Have to read it like this otherwise it won't look right 202 | uint8_t PlayerID0 = r.Read(); 203 | uint8_t PlayerID1 = r.Read(); 204 | uint8_t PlayerID2 = r.Read(); 205 | uint8_t PlayerID3 = r.Read(); 206 | 207 | char temp[16] = {0}; 208 | sprintf_s(temp, "%.2X %.2X %.2X %.2X", PlayerID0, PlayerID1, PlayerID2, PlayerID3); 209 | 210 | ui.PlayerID->setText(temp); 211 | r.SeekRead(0, Seek_Set); 212 | } 213 | //Object selected 214 | else if(opcode == 0x7045) 215 | { 216 | //Have to read it like this otherwise it won't look right 217 | uint8_t Object0 = r.Read(); 218 | uint8_t Object1 = r.Read(); 219 | uint8_t Object2 = r.Read(); 220 | uint8_t Object3 = r.Read(); 221 | 222 | char temp[16] = {0}; 223 | sprintf_s(temp, "%.2X %.2X %.2X %.2X", Object0, Object1, Object2, Object3); 224 | 225 | ui.SelectedObject->setText(temp); 226 | r.SeekRead(0, Seek_Set); 227 | } 228 | 229 | //Check the ignore list 230 | bool found = false; 231 | for(int x = 0; x < ui.lstIgnore->count(); ++x) 232 | { 233 | bool OK; 234 | if(ui.lstIgnore->item(x)->text().toUInt(&OK, 16) == opcode) 235 | { 236 | found = true; 237 | break; 238 | } 239 | } 240 | if(found) continue; 241 | 242 | //Check the listen list 243 | if(ui.lstListen->count()) 244 | { 245 | found = false; 246 | for(int x = 0; x < ui.lstListen->count(); ++x) 247 | { 248 | bool OK; 249 | if(ui.lstListen->item(x)->text().toUInt(&OK, 16) == opcode) 250 | { 251 | found = true; 252 | break; 253 | } 254 | } 255 | 256 | if(!found) 257 | continue; 258 | } 259 | 260 | //Parse the packet for reading 261 | std::stringstream ss; 262 | ss << "[" << (direction == 1 ? "C->S" : "S->C") << "] "; 263 | ss << "[" << size << "] "; 264 | ss << "[0x" << std::hex << std::setfill('0') << std::setw(4) << opcode << "] " << std::dec; 265 | ss << (encrypted ? "[E] " : "") << "\n"; 266 | ss << DumpToString(r); 267 | 268 | bool append = false; 269 | if(direction == 0 && ui.chkServer->isChecked()) 270 | { 271 | if(ui.chkEncrypted->isChecked() && encrypted) 272 | append = true; 273 | if(!ui.chkEncrypted->isChecked()) 274 | append = true; 275 | } 276 | else if(direction == 1 && ui.chkClient->isChecked()) 277 | { 278 | if(ui.chkEncrypted->isChecked() && encrypted) 279 | append = true; 280 | if(!ui.chkEncrypted->isChecked()) 281 | append = true; 282 | } 283 | 284 | //Append the packet to the list 285 | if(append) 286 | ui.lstPackets->appendPlainText(ss.str().c_str()); 287 | } 288 | else 289 | { 290 | //Not enough bytes received for this packet 291 | break; 292 | } 293 | } 294 | } 295 | 296 | //Saves packets 297 | void phAnalyzer::Save() 298 | { 299 | //Retrieve the packets from the user interface 300 | QString packets = ui.lstPackets->toPlainText(); 301 | 302 | if(!packets.isEmpty()) 303 | { 304 | //Ask the user where to save the packets 305 | QString path = QFileDialog::getSaveFileName(this, "Save Packet", "", "Text Documents (*.txt)"); 306 | 307 | //Valid path check 308 | if(!path.isEmpty()) 309 | { 310 | //Open the file 311 | QFile file(path); 312 | if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) 313 | { 314 | QMessageBox::critical(this, "Error", "Failed to open file for writing: " + path); 315 | } 316 | else 317 | { 318 | //Write the packets to the text document 319 | QTextStream out(&file); 320 | out << packets; 321 | 322 | //Close the file 323 | file.close(); 324 | } 325 | } 326 | } 327 | else 328 | { 329 | QMessageBox::warning(this, "Save Packets", "There is no packet data to save."); 330 | } 331 | } 332 | 333 | //Clears the packet window 334 | void phAnalyzer::Clear() 335 | { 336 | //Clear packet list 337 | ui.lstPackets->clear(); 338 | } 339 | 340 | //Displays the packet injection window 341 | void phAnalyzer::Inject() 342 | { 343 | //Show the window 344 | if(inj) inj->show(); 345 | } 346 | 347 | //Right click menu for removing opcodes 348 | void phAnalyzer::RemoveOpcodeMenu(const QPoint & pos) 349 | { 350 | //Create menu 351 | QMenu menu(this); 352 | menu.addAction("Remove"); 353 | 354 | if(ui.lstIgnore->hasFocus()) 355 | { 356 | //Make sure there are selected items before displaying the context menu 357 | if(!ui.lstIgnore->selectedItems().size()) return; 358 | 359 | //Get position on the list widget for drawing the menu 360 | QPoint globalPos = ui.lstIgnore->mapToGlobal(pos); 361 | QAction* action = menu.exec(globalPos); 362 | 363 | if(action && action->text() == "Remove") 364 | { 365 | //Get selected items and delete them 366 | qDeleteAll(ui.lstIgnore->selectedItems()); 367 | } 368 | } 369 | else if(ui.lstListen->hasFocus()) 370 | { 371 | //Make sure there are selected items before displaying the context menu 372 | if(!ui.lstListen->selectedItems().size()) return; 373 | 374 | //Get position on the list widget for drawing the menu 375 | QPoint globalPos = ui.lstListen->mapToGlobal(pos); 376 | QAction* action = menu.exec(globalPos); 377 | 378 | if(action && action->text() == "Remove") 379 | { 380 | //Get selected items and delete them 381 | qDeleteAll(ui.lstListen->selectedItems()); 382 | } 383 | } 384 | } -------------------------------------------------------------------------------- /phAnalyzer/analyzer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ANALYZER_H 4 | #define ANALYZER_H 5 | 6 | #include 7 | #include "ui_analyzer.h" 8 | #include "injection.h" 9 | #include "Stream/stream_utility.h" 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | class phAnalyzer : public QWidget 21 | { 22 | Q_OBJECT 23 | 24 | private: 25 | 26 | //User interface 27 | Ui::phAnalyzerClass ui; 28 | 29 | //TCP socket 30 | QTcpSocket* socket; 31 | 32 | //Received data 33 | std::vector data; 34 | 35 | //Packet stuff 36 | StreamUtility pending_stream; 37 | 38 | //Packet injector UI 39 | injection* inj; 40 | 41 | //Connection info 42 | QString HOST; 43 | uint16_t PORT; 44 | 45 | private slots: 46 | 47 | //Adds an opcode to the ignore list when the enter key is pressed 48 | void AddIgnoreOpcode(); 49 | 50 | //Adds an opcode to the listen list when the enter key is pressed 51 | void AddListenOpcode(); 52 | 53 | //Socket connected 54 | void Connected(); 55 | 56 | //Socket state changed 57 | void SocketState(QAbstractSocket::SocketState state); 58 | 59 | //Read data 60 | void readyRead(); 61 | 62 | //Saves packets 63 | void Save(); 64 | 65 | //Clears the packet window 66 | void Clear(); 67 | 68 | //Displays the packet injection window 69 | void Inject(); 70 | 71 | //Right click menu for removing opcodes 72 | void RemoveOpcodeMenu(const QPoint & pos); 73 | 74 | protected: 75 | 76 | //Processes close events 77 | void closeEvent(QCloseEvent* event); 78 | 79 | public: 80 | 81 | //Constructor 82 | phAnalyzer(QWidget *parent = 0, Qt::WFlags flags = 0); 83 | 84 | //Destructor 85 | ~phAnalyzer(); 86 | }; 87 | 88 | #endif -------------------------------------------------------------------------------- /phAnalyzer/analyzer.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | PH.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /phAnalyzer/analyzer.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | phAnalyzerClass 4 | 5 | 6 | 7 | 0 8 | 0 9 | 851 10 | 730 11 | 12 | 13 | 14 | 15 | 851 16 | 730 17 | 18 | 19 | 20 | 21 | 851 22 | 730 23 | 24 | 25 | 26 | phAnalyzer - ProjectHax.com - Disconnected 27 | 28 | 29 | 30 | :/phAnalyzer/PH.png:/phAnalyzer/PH.png 31 | 32 | 33 | 34 | 35 | 0 36 | 0 37 | 852 38 | 21 39 | 40 | 41 | 42 | 43 | File 44 | 45 | 46 | 47 | 48 | 49 | Packets 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 10 61 | 30 62 | 51 63 | 17 64 | 65 | 66 | 67 | Server 68 | 69 | 70 | true 71 | 72 | 73 | 74 | 75 | 76 | 70 77 | 30 78 | 51 79 | 17 80 | 81 | 82 | 83 | Client 84 | 85 | 86 | true 87 | 88 | 89 | 90 | 91 | 92 | 130 93 | 30 94 | 91 95 | 17 96 | 97 | 98 | 99 | Encrypted only 100 | 101 | 102 | false 103 | 104 | 105 | 106 | 107 | 108 | 550 109 | 30 110 | 81 111 | 21 112 | 113 | 114 | 115 | Selected object: 116 | 117 | 118 | 119 | 120 | 121 | 350 122 | 30 123 | 51 124 | 21 125 | 126 | 127 | 128 | Player ID: 129 | 130 | 131 | 132 | 133 | 134 | 410 135 | 30 136 | 113 137 | 20 138 | 139 | 140 | 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 640 148 | 30 149 | 113 150 | 20 151 | 152 | 153 | 154 | true 155 | 156 | 157 | 158 | 159 | 160 | 90 161 | 60 162 | 751 163 | 631 164 | 165 | 166 | 167 | 168 | Courier 169 | 10 170 | 171 | 172 | 173 | true 174 | 175 | 176 | 177 | 178 | 179 | 10 180 | 110 181 | 71 182 | 261 183 | 184 | 185 | 186 | Qt::CustomContextMenu 187 | 188 | 189 | 190 | 191 | 192 | 10 193 | 80 194 | 71 195 | 20 196 | 197 | 198 | 199 | 4 200 | 201 | 202 | 203 | 204 | 205 | 10 206 | 60 207 | 46 208 | 13 209 | 210 | 211 | 212 | Ignore 213 | 214 | 215 | 216 | 217 | 218 | 10 219 | 390 220 | 46 221 | 13 222 | 223 | 224 | 225 | Listen 226 | 227 | 228 | 229 | 230 | 231 | 10 232 | 410 233 | 71 234 | 20 235 | 236 | 237 | 238 | 4 239 | 240 | 241 | 242 | 243 | 244 | 10 245 | 440 246 | 71 247 | 251 248 | 249 | 250 | 251 | Qt::CustomContextMenu 252 | 253 | 254 | 255 | 256 | 257 | 170 258 | 700 259 | 75 260 | 23 261 | 262 | 263 | 264 | Clear 265 | 266 | 267 | 268 | 269 | 270 | 90 271 | 700 272 | 75 273 | 23 274 | 275 | 276 | 277 | Save 278 | 279 | 280 | 281 | 282 | 283 | 250 284 | 30 285 | 51 286 | 17 287 | 288 | 289 | 290 | Pause 291 | 292 | 293 | false 294 | 295 | 296 | 297 | 298 | Save Packets 299 | 300 | 301 | 302 | 303 | Exit 304 | 305 | 306 | 307 | 308 | Save 309 | 310 | 311 | 312 | 313 | Inject 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | txtIgnore 324 | returnPressed() 325 | phAnalyzerClass 326 | AddIgnoreOpcode() 327 | 328 | 329 | 64 330 | 85 331 | 332 | 333 | 72 334 | 60 335 | 336 | 337 | 338 | 339 | txtListen 340 | returnPressed() 341 | phAnalyzerClass 342 | AddListenOpcode() 343 | 344 | 345 | 64 346 | 426 347 | 348 | 349 | 76 350 | 391 351 | 352 | 353 | 354 | 355 | btnClear 356 | clicked() 357 | phAnalyzerClass 358 | Clear() 359 | 360 | 361 | 224 362 | 710 363 | 364 | 365 | 280 366 | 706 367 | 368 | 369 | 370 | 371 | btnSave 372 | clicked() 373 | phAnalyzerClass 374 | Save() 375 | 376 | 377 | 130 378 | 715 379 | 380 | 381 | 61 382 | 711 383 | 384 | 385 | 386 | 387 | 388 | AddIgnoreOpcode() 389 | AddListenOpcode() 390 | Clear() 391 | Save() 392 | 393 | 394 | -------------------------------------------------------------------------------- /phAnalyzer/injection.cpp: -------------------------------------------------------------------------------- 1 | #include "injection.h" 2 | 3 | #include 4 | 5 | //Constructor 6 | injection::injection(QWidget *parent, QTcpSocket* socket_) : QWidget(parent), socket(socket_) 7 | { 8 | //Sets up the user interface 9 | ui.setupUi(this); 10 | } 11 | 12 | //Destructor 13 | injection::~injection() 14 | { 15 | } 16 | 17 | //Injects a packet into Silkroad 18 | void injection::Inject() 19 | { 20 | //Connected check 21 | if(!socket || socket->state() != QAbstractSocket::ConnectedState) 22 | { 23 | QMessageBox::critical(this, "Error", "The analyzer is not currently connected to anything."); 24 | return; 25 | } 26 | 27 | StreamUtility w; 28 | QString opcode = ui.txtOpcode->text(); 29 | QString data = ui.txtData->text().replace(" ", ""); 30 | 31 | //Opcode length check 32 | if(opcode.length() != 4) 33 | { 34 | QMessageBox::warning(this, "Error", "Packet opcode length must be 4."); 35 | return; 36 | } 37 | 38 | //Data length check 39 | if((data.length() % 2) != 0) 40 | { 41 | QMessageBox::warning(this, "Error", "Packet data must be a multiple of 2."); 42 | return; 43 | } 44 | 45 | //Convert the opcode 46 | bool OK; 47 | uint16_t temp = opcode.toUInt(&OK, 16); 48 | 49 | if(!OK) 50 | { 51 | QMessageBox::warning(this, "Error", "There was a problem converting the opcode to an unsigned short."); 52 | return; 53 | } 54 | 55 | //Packet size 56 | w.Write(data.length() ? data.length() / 2 : 0); 57 | 58 | //Packet opcode 59 | w.Write(temp); 60 | 61 | //Direction 62 | if(ui.radServer->isChecked()) 63 | { 64 | w.Write(ui.chkEncrypted->isChecked() ? 3 : 1); 65 | } 66 | else 67 | { 68 | w.Write(ui.chkEncrypted->isChecked() ? 4 : 2); 69 | } 70 | 71 | w.Write(0); 72 | 73 | //Convert the data to hex bytes 74 | for(int x = 0; x < data.length(); x += 2) 75 | { 76 | uint8_t byte = data.mid(x, 2).toUInt(&OK, 16); 77 | if(!OK) 78 | { 79 | QMessageBox::warning(this, "Error", QString("There was a problem converting a byte in your packet at index %0").arg(x)); 80 | return; 81 | } 82 | 83 | w.Write(byte); 84 | } 85 | 86 | //Inject 87 | socket->write((const char*)w.GetStreamPtr(), w.GetStreamSize()); 88 | } -------------------------------------------------------------------------------- /phAnalyzer/injection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef INJECTION_H 4 | #define INJECTION_H 5 | 6 | #include 7 | #include "ui_injection.h" 8 | #include 9 | 10 | #include 11 | #include "Stream/stream_utility.h" 12 | 13 | class injection : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | private: 18 | 19 | //User interface 20 | Ui::injection ui; 21 | 22 | //Socket 23 | QTcpSocket* socket; 24 | 25 | private slots: 26 | 27 | //Injects a packet into Silkroad 28 | void Inject(); 29 | 30 | public: 31 | 32 | //Constructor 33 | injection(QWidget *parent = 0, QTcpSocket* socket_ = 0); 34 | 35 | //Destructor 36 | ~injection(); 37 | }; 38 | 39 | #endif -------------------------------------------------------------------------------- /phAnalyzer/injection.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | injection 4 | 5 | 6 | 7 | 0 8 | 0 9 | 497 10 | 89 11 | 12 | 13 | 14 | 15 | 497 16 | 89 17 | 18 | 19 | 20 | 21 | 497 22 | 89 23 | 24 | 25 | 26 | Silkroad Packet Injector - ProjectHax.com 27 | 28 | 29 | 30 | :/phAnalyzer/PH.png:/phAnalyzer/PH.png 31 | 32 | 33 | 34 | 35 | 10 36 | 30 37 | 61 38 | 20 39 | 40 | 41 | 42 | 7021 43 | 44 | 45 | 4 46 | 47 | 48 | 49 | 50 | 51 | 80 52 | 30 53 | 401 54 | 20 55 | 56 | 57 | 58 | 00 01 fd d1 59 | 60 | 61 | 62 | 63 | 64 | 70 65 | 60 66 | 51 67 | 17 68 | 69 | 70 | 71 | Client 72 | 73 | 74 | false 75 | 76 | 77 | 78 | 79 | 80 | 10 81 | 60 82 | 61 83 | 17 84 | 85 | 86 | 87 | Server 88 | 89 | 90 | true 91 | 92 | 93 | 94 | 95 | 96 | 140 97 | 60 98 | 70 99 | 17 100 | 101 | 102 | 103 | Encrypted 104 | 105 | 106 | 107 | 108 | 109 | 400 110 | 60 111 | 75 112 | 23 113 | 114 | 115 | 116 | Inject 117 | 118 | 119 | 120 | 121 | 122 | 10 123 | 10 124 | 46 125 | 13 126 | 127 | 128 | 129 | Opcode 130 | 131 | 132 | 133 | 134 | 135 | 80 136 | 10 137 | 61 138 | 16 139 | 140 | 141 | 142 | Packet data 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | btnInject 153 | clicked() 154 | injection 155 | Inject() 156 | 157 | 158 | 416 159 | 70 160 | 161 | 162 | 365 163 | 67 164 | 165 | 166 | 167 | 168 | 169 | Inject() 170 | 171 | 172 | -------------------------------------------------------------------------------- /phAnalyzer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "analyzer.h" 3 | #include 4 | 5 | #if _DEBUG 6 | #include "io.h" 7 | #include "fcntl.h" 8 | #include "windows.h" 9 | 10 | void CreateConsole(const char *winTitle) 11 | { 12 | //http://www.gamedev.net/community/forums/viewreply.asp?ID=1958358 13 | int hConHandle = 0; 14 | HANDLE lStdHandle = 0; 15 | FILE *fp = 0 ; 16 | 17 | AllocConsole(); 18 | if(winTitle) 19 | SetConsoleTitleA(winTitle); 20 | 21 | // redirect unbuffered STDOUT to the console 22 | lStdHandle = GetStdHandle(STD_OUTPUT_HANDLE); 23 | hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), _O_TEXT); 24 | fp = _fdopen(hConHandle, "w"); 25 | *stdout = *fp; 26 | setvbuf(stdout, NULL, _IONBF, 0); 27 | 28 | // redirect unbuffered STDIN to the console 29 | lStdHandle = GetStdHandle(STD_INPUT_HANDLE); 30 | hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), _O_TEXT); 31 | fp = _fdopen(hConHandle, "r"); 32 | *stdin = *fp; 33 | setvbuf(stdin, NULL, _IONBF, 0); 34 | 35 | // redirect unbuffered STDERR to the console 36 | lStdHandle = GetStdHandle(STD_ERROR_HANDLE); 37 | hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), _O_TEXT); 38 | fp = _fdopen(hConHandle, "w"); 39 | *stderr = *fp; 40 | setvbuf(stderr, NULL, _IONBF, 0); 41 | } 42 | #endif 43 | 44 | int main(int argc, char *argv[]) 45 | { 46 | #if _DEBUG 47 | CreateConsole(0); 48 | #endif 49 | 50 | QApplication a(argc, argv); 51 | phAnalyzer w; 52 | w.show(); 53 | return a.exec(); 54 | } -------------------------------------------------------------------------------- /phAnalyzer/phAnalyzer.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectHax/phAnalyzer/a33869dabbfe6d3427fba117f6dcb283e3d9c51f/phAnalyzer/phAnalyzer.rc -------------------------------------------------------------------------------- /phAnalyzer/phAnalyzer.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {DC6372E9-682D-4046-9662-62423CDEC055} 15 | Qt4VSv1.0 16 | 17 | 18 | 19 | Application 20 | Unicode 21 | 22 | 23 | Application 24 | Unicode 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | <_ProjectFileVersion>10.0.40219.1 38 | AllRules.ruleset 39 | 40 | 41 | AllRules.ruleset 42 | 43 | 44 | $(SolutionDir)$(Configuration)\ 45 | $(SolutionDir)$(Configuration)\ 46 | $(IncludePath) 47 | $(LibraryPath) 48 | $(IncludePath) 49 | $(LibraryPath) 50 | 51 | 52 | 53 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_GUI_LIB;QT_CORE_LIB;_WIN32_WINNT=0x0502;QT_NETWORK_LIB;%(PreprocessorDefinitions) 54 | .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 55 | Disabled 56 | ProgramDatabase 57 | MultiThreadedDebugDLL 58 | true 59 | true 60 | true 61 | EnableFastChecks 62 | 63 | 64 | Windows 65 | $(OutDir)\$(ProjectName).exe 66 | $(QTDIR)\lib;%(AdditionalLibraryDirectories) 67 | kernel32.lib;user32.lib;shell32.lib;uuid.lib;ole32.lib;advapi32.lib;ws2_32.lib;gdi32.lib;comdlg32.lib;oleaut32.lib;imm32.lib;winmm.lib;winspool.lib;qtmaind.lib;QtCored.lib;QtGuid.lib;QtNetworkd.lib;%(AdditionalDependencies) 68 | true 69 | true 70 | 71 | 72 | 73 | 74 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) 75 | .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 76 | 77 | 78 | MultiThreadedDLL 79 | true 80 | true 81 | MaxSpeed 82 | 83 | 84 | Windows 85 | $(OutDir)\$(ProjectName).exe 86 | $(QTDIR)\lib;%(AdditionalLibraryDirectories) 87 | kernel32.lib;user32.lib;shell32.lib;uuid.lib;ole32.lib;advapi32.lib;ws2_32.lib;gdi32.lib;comdlg32.lib;oleaut32.lib;imm32.lib;winmm.lib;winspool.lib;qtmain.lib;QtCore.lib;QtGui.lib;QtNetwork.lib;%(AdditionalDependencies) 88 | true 89 | true 90 | 91 | 92 | 93 | 94 | 95 | true 96 | 97 | 98 | true 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | true 108 | 109 | 110 | true 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | $(QTDIR)\bin\moc.exe;%(FullPath) 119 | Moc%27ing analyzer.h... 120 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 121 | "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_GUI_LIB -DQT_CORE_LIB -D_WIN32_WINNT=0x0502 -DQT_NETWORK_LIB -D_UNICODE "-I." "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I$(QTDIR)\include\QtNetwork" "-I." "-I." "-I." "-I." "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" 122 | $(QTDIR)\bin\moc.exe;%(FullPath) 123 | Moc%27ing analyzer.h... 124 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 125 | "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D_UNICODE "-I." "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I$(QTDIR)\include\QtNetwork" "-I." "-I." "-I." "-I." "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" 126 | 127 | 128 | 129 | 130 | Document 131 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 132 | Uic%27ing %(Identity)... 133 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 134 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 135 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 136 | Uic%27ing %(Identity)... 137 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 138 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 139 | 140 | 141 | 142 | 143 | 144 | $(QTDIR)\bin\moc.exe;%(FullPath) 145 | Moc%27ing injection.h... 146 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 147 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_GUI_LIB -DQT_CORE_LIB -D_WIN32_WINNT=0x0502 -DQT_NETWORK_LIB -D_UNICODE "-I." "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I$(QTDIR)\include\QtNetwork" "-I." "-I." "-I." "-I." 148 | $(QTDIR)\bin\moc.exe;%(FullPath) 149 | Moc%27ing injection.h... 150 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 151 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D_UNICODE "-I." "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I$(QTDIR)\include\QtNetwork" "-I." "-I." "-I." "-I." 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | Document 160 | %(FullPath);%(AdditionalInputs) 161 | Rcc%27ing %(Identity)... 162 | .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) 163 | "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp 164 | %(FullPath);%(AdditionalInputs) 165 | Rcc%27ing %(Identity)... 166 | .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) 167 | "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | Document 176 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 177 | Uic%27ing %(Identity)... 178 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 179 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 180 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 181 | Uic%27ing %(Identity)... 182 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 183 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /phAnalyzer/phAnalyzer.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 6 | qrc;* 7 | false 8 | 9 | 10 | {99349809-55BA-4b9d-BF79-8FDBB0286EB3} 11 | ui 12 | 13 | 14 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 15 | moc;h;cpp 16 | False 17 | 18 | 19 | {f0ae604e-a57f-4d5c-b632-40c8f6d294f3} 20 | cpp;moc 21 | False 22 | 23 | 24 | {8ef41b15-7698-4c9e-9542-fd8961fc0468} 25 | cpp;moc 26 | False 27 | 28 | 29 | {60f5e0e6-de48-49e5-8aa3-2d68c0c8e676} 30 | 31 | 32 | 33 | 34 | Resource Files\Generated Files\Debug 35 | 36 | 37 | Resource Files\Generated Files\Release 38 | 39 | 40 | Resource Files\Generated Files 41 | 42 | 43 | Resource Files 44 | 45 | 46 | 47 | Stream 48 | 49 | 50 | Resource Files\Generated Files\Debug 51 | 52 | 53 | Resource Files\Generated Files\Release 54 | 55 | 56 | Resource Files 57 | 58 | 59 | 60 | 61 | Resource Files\Form Files 62 | 63 | 64 | Resource Files 65 | 66 | 67 | Resource Files 68 | 69 | 70 | Resource Files\Form Files 71 | 72 | 73 | Resource Files 74 | 75 | 76 | 77 | 78 | Resource Files\Generated Files 79 | 80 | 81 | Resource Files 82 | 83 | 84 | Stream 85 | 86 | 87 | Resource Files\Generated Files 88 | 89 | 90 | 91 | 92 | Resource Files 93 | 94 | 95 | 96 | 97 | Resource Files 98 | 99 | 100 | -------------------------------------------------------------------------------- /phAnalyzer/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectHax/phAnalyzer/a33869dabbfe6d3427fba117f6dcb283e3d9c51f/phAnalyzer/resource.h --------------------------------------------------------------------------------