├── .travis.yml ├── PacketViewer ├── icon.ico ├── Libs │ ├── SharpPcap.dll │ ├── Tera.Core.dll │ ├── PacketDotNet.dll │ ├── NetworkSniffer.dll │ ├── Tera.Sniffing.dll │ └── serverlist.xml ├── App.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Network │ ├── Lists │ │ ├── IPacketList.cs │ │ ├── PacketStream.cs │ │ ├── PacketQueue.cs │ │ └── PacketList.cs │ ├── Packet_old.cs │ ├── PacketTranslator.cs │ ├── Capture.cs │ └── PacketProcessor.cs ├── Classes │ ├── IPacketInput.cs │ ├── Configuration.cs │ ├── ServerInfo.cs │ ├── PacketFilter.cs │ ├── WireshackReader.cs │ └── TeraLogReader.cs ├── App.xaml.cs ├── App.xaml ├── Forms │ ├── Style.xaml │ ├── MainWindow.xaml │ └── MainWindow.xaml.cs ├── Program.cs ├── MiscFuncs.cs └── PacketViewer.csproj ├── Opcode DLL ├── OpcodeDLL_3009.dll ├── Extreme Injector v3.exe ├── OpcodeDLL │ ├── OpcodeDLL │ │ ├── stdafx.h │ │ ├── stdafx.cpp │ │ ├── OpcodeDLL.cpp │ │ ├── targetver.h │ │ ├── OpcodeDLL.vcxproj.filters │ │ ├── dllmain.cpp │ │ ├── ReadMe.txt │ │ └── OpcodeDLL.vcxproj │ └── OpcodeDLL.sln ├── README.txt ├── settings.xml └── 3009_OpCodes_Dec.txt ├── .gitmodules ├── .gitattributes ├── README.md ├── .gitignore └── Tera.sln /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | solution: Tera.sln -------------------------------------------------------------------------------- /PacketViewer/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/PacketViewer/icon.ico -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL_3009.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/Opcode DLL/OpcodeDLL_3009.dll -------------------------------------------------------------------------------- /PacketViewer/Libs/SharpPcap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/PacketViewer/Libs/SharpPcap.dll -------------------------------------------------------------------------------- /PacketViewer/Libs/Tera.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/PacketViewer/Libs/Tera.Core.dll -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/TDM"] 2 | path = external/TDM 3 | url = https://github.com/GoneUp/TeraDamageMeter.git 4 | -------------------------------------------------------------------------------- /Opcode DLL/Extreme Injector v3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/Opcode DLL/Extreme Injector v3.exe -------------------------------------------------------------------------------- /PacketViewer/Libs/PacketDotNet.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/PacketViewer/Libs/PacketDotNet.dll -------------------------------------------------------------------------------- /PacketViewer/Libs/NetworkSniffer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/PacketViewer/Libs/NetworkSniffer.dll -------------------------------------------------------------------------------- /PacketViewer/Libs/Tera.Sniffing.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/PacketViewer/Libs/Tera.Sniffing.dll -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/Opcode DLL/OpcodeDLL/OpcodeDLL/stdafx.h -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/Opcode DLL/OpcodeDLL/OpcodeDLL/stdafx.cpp -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL/OpcodeDLL.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/Opcode DLL/OpcodeDLL/OpcodeDLL/OpcodeDLL.cpp -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoneUp/Tera_PacketViewer/HEAD/Opcode DLL/OpcodeDLL/OpcodeDLL/targetver.h -------------------------------------------------------------------------------- /PacketViewer/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PacketViewer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /PacketViewer/Network/Lists/IPacketList.cs: -------------------------------------------------------------------------------- 1 | namespace PacketViewer.Network.Lists 2 | { 3 | public interface IPacketList 4 | { 5 | void Clear(); 6 | void Enqueue(byte[] data); 7 | byte[] GetBytes(int length); 8 | int GetLength(); 9 | bool PacketAvailable(); 10 | int NextPacketLength(); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /PacketViewer/Classes/IPacketInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using PacketViewer.Network; 7 | 8 | namespace PacketViewer.Classes 9 | { 10 | interface IPacketInput 11 | { 12 | void SetProcessor(PacketProcessor pp); 13 | void Process(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PacketViewer/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace PacketViewer 9 | { 10 | /// 11 | /// Interaction logic for App.xaml 12 | /// 13 | public partial class App : Application 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tera_PacketViewer 2 | 3 | The purpose of this project is to sniff and show the network traffic of the MMO "Tera" directly in the program. 4 | 5 | ### Usage 6 | Instructions how to use this software are at my ragezone release thread: http://forum.ragezone.com/f797/release-tera-live-packet-sniffer-1052922/ 7 | 8 | ### Notes 9 | * Get the full repo including the submodules via 10 | ```git clone --recursive https://github.com/GoneUp/Tera_PacketViewer.git ``` 11 | * Use any Visual Studio 2012+ 12 | 13 | -------------------------------------------------------------------------------- /PacketViewer/Classes/Configuration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PacketViewer.Classes 8 | { 9 | public class Configuration 10 | { 11 | private readonly List servers; 12 | 13 | public Configuration(List servers) 14 | { 15 | this.servers = servers; 16 | } 17 | 18 | public List getServers() 19 | { 20 | return servers; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /PacketViewer/App.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /PacketViewer/Classes/ServerInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Tera.Game; 7 | 8 | namespace PacketViewer.Classes 9 | { 10 | public class ServerInfo : Server 11 | { 12 | public bool Focus; 13 | public bool AutoStart; 14 | 15 | public ServerInfo(string name, string ip, bool focus, bool autoStart) : base(name, "", ip) 16 | { 17 | Focus = focus; 18 | AutoStart = autoStart; 19 | } 20 | 21 | public override string ToString() 22 | { 23 | //Format: 79.110.94.217;EU Akasha 24 | return String.Format("{0};{1}", Ip, Name); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpcodeDLL", "OpcodeDLL\OpcodeDLL.vcxproj", "{E7E18D39-C539-4717-A2C7-1F21C12A0233}" 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 | {E7E18D39-C539-4717-A2C7-1F21C12A0233}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {E7E18D39-C539-4717-A2C7-1F21C12A0233}.Debug|Win32.Build.0 = Debug|Win32 14 | {E7E18D39-C539-4717-A2C7-1F21C12A0233}.Release|Win32.ActiveCfg = Release|Win32 15 | {E7E18D39-C539-4717-A2C7-1F21C12A0233}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /PacketViewer/Forms/Style.xaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 15 | 19 | -------------------------------------------------------------------------------- /PacketViewer/Classes/PacketFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using PacketViewer.Network; 7 | 8 | namespace PacketViewer.Classes 9 | { 10 | internal class PacketFilter 11 | { 12 | public List ignoreOpcodes = new List(); 13 | public List showOnlyOpcodes = new List(); 14 | 15 | public bool showCS = true; 16 | public bool showSC = true; 17 | public bool showAny = true; 18 | 19 | public bool ShowPacket(Packet_old packet) 20 | { 21 | if (!showAny) return false; 22 | if (packet.Dir == Direction.CS && !showCS) return false; 23 | if (packet.Dir == Direction.SC && !showSC) return false; 24 | 25 | if (showOnlyOpcodes.Count > 0) 26 | { 27 | return showOnlyOpcodes.Contains(packet.OpCode); 28 | } 29 | else 30 | { 31 | return !ignoreOpcodes.Contains(packet.OpCode); 32 | } 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Opcode DLL/README.txt: -------------------------------------------------------------------------------- 1 | Guide to the Opcode DLL: 2 | 3 | Code from tagyourit50, released at ragezone: http://forum.ragezone.com/f797/release-tera-live-packet-sniffer-1052922-post8369480/#post8369480 4 | 5 | 6 | ######### 7 | Post Copy: 8 | For those wondering how to get the opcode names here's a little guide. 9 | 10 | 1. In cheat engine, find the function that references the string "I_TELEPORT". Look just above that and find the start of the function. (In this case 0x0191D0A0) 11 | --Use the view -> referenced strings function, search for I_TELEPORT there. 12 | 13 | 14 | 2. Make a c++ dll that looks like http://pastebin.com/qTGzrW8w with the address that you got in the previous step. 15 | 16 | 3. Now inject it into the Tera process, after which you should see some message boxes. 17 | Click OK on those, then in your TERA\Client\Binaries folder you should see a file called opcodes.txt full of opcodes. 18 | (You can just change the output directory if you want) 19 | 20 | ####### 21 | 22 | 23 | If you want to use the file with the packet editor, use the decimal output file, copy it to the packetviewer directory and name it "opcodefile.txt" 24 | 25 | ###### 26 | GoneUp 27 | -------------------------------------------------------------------------------- /PacketViewer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17379 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PacketViewer.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PacketViewer/Network/Packet_old.cs: -------------------------------------------------------------------------------- 1 | namespace PacketViewer.Network 2 | { 3 | public class Packet_old 4 | { 5 | public Direction Dir; 6 | public ushort OpCode; 7 | public string OpName; 8 | 9 | public byte[] Data; 10 | public string HexShortText; 11 | public string HexLongText; 12 | 13 | public Packet_old(Direction dir, ushort opCode, byte[] data, bool hexWithSpaces) 14 | { 15 | Dir = dir; 16 | OpCode = opCode; 17 | Data = data; 18 | OpName = PacketTranslator.GetOpcodeName(opCode); ; 19 | 20 | HexShortText = Data.ToHex(); 21 | HexLongText = "0x" + string.Format("{0:X4}", opCode) + "\n\n" + Data.FormatHex(); 22 | 23 | if (hexWithSpaces) 24 | { 25 | string newHex = ""; 26 | for (int i = 0; i < HexShortText.Length; i += 2) 27 | { 28 | newHex += HexShortText.Substring(i, 2) + " "; 29 | } 30 | HexShortText = newHex; 31 | } 32 | } 33 | 34 | public override string ToString() 35 | { 36 | return string.Format("[{0}] {1} [{2}]", (Dir == Direction.SC) ? "S" : "C" , OpName, Data.Length); 37 | } 38 | } 39 | 40 | public enum Direction 41 | { 42 | CS, 43 | SC 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL/OpcodeDLL.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Headerdateien 23 | 24 | 25 | Headerdateien 26 | 27 | 28 | 29 | 30 | Quelldateien 31 | 32 | 33 | Quelldateien 34 | 35 | 36 | -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | #include 5 | 6 | //Usinng 7 | using namespace std; 8 | 9 | string OpCodeVersion = "3104"; 10 | DWORD GetOpCodeNameAddress = 0x17E29B0; 11 | 12 | 13 | string GetOpCodeName(DWORD Opcode) 14 | { 15 | unsigned int pointer = 0; 16 | 17 | _asm 18 | { 19 | push Opcode 20 | call GetOpCodeNameAddress 21 | add esp, 4 22 | mov[pointer], eax 23 | } 24 | 25 | return string((LPCSTR)pointer); 26 | } 27 | 28 | DWORD WINAPI Thread(LPVOID nothing) 29 | { 30 | ofstream fileOut; 31 | ofstream fileOut2; 32 | fileOut.open("C:\\" + OpCodeVersion + "_OpCodes_Dec.txt", ios::out); 33 | fileOut2.open("C:\\" + OpCodeVersion + "_OpCodes_Hex.txt", ios::out); 34 | 35 | string name = ""; 36 | 37 | for (int i = 0; i < 0x10000; i++) 38 | { 39 | name = GetOpCodeName(i); 40 | if (name != "") 41 | { 42 | //file dec output 43 | fileOut << name << " = " << i << endl; 44 | 45 | //file2 hex output 46 | fileOut2 << name << " = 0x" << std::hex << i << endl; //this will print the number in hexadecimal 47 | } 48 | } 49 | 50 | fileOut.close(); 51 | fileOut2.close(); 52 | 53 | return 1; 54 | } 55 | 56 | 57 | BOOL WINAPI DllMain(HINSTANCE Hinst, DWORD Reason, LPVOID nothing) 58 | { 59 | switch (Reason) 60 | { 61 | 62 | case DLL_PROCESS_ATTACH: 63 | MessageBoxA(0, "Injected", "Desu", 0); 64 | CreateThread(0, 0, Thread, 0, 0, 0); 65 | case DLL_PROCESS_DETACH: 66 | MessageBoxA(0, "Finished.", "Desu", 0); 67 | } 68 | 69 | return 1; 70 | } -------------------------------------------------------------------------------- /PacketViewer/Libs/serverlist.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /PacketViewer/Classes/WireshackReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using PacketViewer.Forms; 8 | using PacketViewer.Network; 9 | 10 | namespace PacketViewer.Classes 11 | { 12 | class WireshackReader : IPacketInput 13 | { 14 | private FileStream fs; 15 | private TextReader reader; 16 | private PacketProcessor processor; 17 | 18 | public WireshackReader(string file) 19 | { 20 | if (!File.Exists(file)) throw new Exception("File not found!"); 21 | 22 | fs = new FileStream(file, FileMode.Open); 23 | reader = new StreamReader(fs); 24 | } 25 | 26 | public void SetProcessor(PacketProcessor pp) 27 | { 28 | processor = pp; 29 | } 30 | 31 | public void Process() 32 | { 33 | 34 | while (true) 35 | { 36 | string line = reader.ReadLine(); 37 | if (line == null) 38 | break; 39 | if (line.Length == 0) 40 | continue; 41 | 42 | bool isServer = line[0] == ' '; 43 | 44 | string hex = line.Substring(isServer ? 14 : 10, 49).Replace(" ", ""); 45 | byte[] data = hex.ToBytes(); 46 | 47 | if (isServer) 48 | { 49 | processor.AppendServerData(data); 50 | } 51 | else 52 | { 53 | processor.AppendClientData(data); 54 | } 55 | 56 | if (!processor.Initialized) processor.TryInit(); 57 | processor.ProcessAllClientData(); 58 | processor.ProcessAllServerData(); 59 | } 60 | 61 | reader.Close(); 62 | } 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /PacketViewer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | 11 | namespace PacketViewer 12 | { 13 | public class Program 14 | { 15 | [STAThreadAttribute] 16 | public static void Main() 17 | { 18 | try 19 | { 20 | AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly; 21 | App.Main(); 22 | } 23 | catch (Exception ex) 24 | { 25 | MessageBox.Show("Assembly Err: " + ex); 26 | } 27 | 28 | } 29 | 30 | private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args) 31 | { 32 | 33 | 34 | Assembly executingAssembly = Assembly.GetExecutingAssembly(); 35 | AssemblyName assemblyName = new AssemblyName(args.Name); 36 | 37 | string path = assemblyName.Name + ".dll"; 38 | if (assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false) 39 | { 40 | path = String.Format(@"{0}\{1}", assemblyName.CultureInfo, path); 41 | } 42 | else 43 | { 44 | //fix for our subfolder 45 | path = String.Format("PacketViewer.Libs.{0}.dll", assemblyName.Name); 46 | } 47 | 48 | using (Stream stream = executingAssembly.GetManifestResourceStream(path)) 49 | { 50 | if (stream == null) 51 | return null; 52 | 53 | byte[] assemblyRawBytes = new byte[stream.Length]; 54 | stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length); 55 | return Assembly.Load(assemblyRawBytes); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Opcode DLL/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | I:\Henry\Projekte\Tera\Tera_PacketViewer\Opcode DLL\OpcodeDLL_3104.dll 7 | 8 | 9 | 10 | 11 | false 12 | false 13 | false 14 | false 15 | 16 | false 17 | DodgerBlue 18 | DeepSkyBlue 19 | false 20 | 0 21 | 0 22 | false 23 | false 24 | 0 25 | 26 | false 27 | false 28 | false 29 | false 30 | false 31 | false 32 | false 33 | false 34 | false 35 | false 36 | false 37 | false 38 | false 39 | 40 | false 41 | White 42 | 43 | TERA.exe 44 | 45 | false 46 | false 47 | false 48 | 49 | -------------------------------------------------------------------------------- /PacketViewer/Network/PacketTranslator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Windows; 6 | using PacketViewer.Forms; 7 | 8 | namespace PacketViewer.Network 9 | { 10 | class PacketTranslator 11 | { 12 | public static Dictionary PacketNames = new Dictionary(); 13 | 14 | public static void Init() 15 | { 16 | string path = Directory.GetCurrentDirectory() + "\\opcodefile.txt"; 17 | if (File.Exists(path)) 18 | { 19 | TextReader reader = new StreamReader(path); 20 | 21 | string line = ""; 22 | while ((line = reader.ReadLine()) != null) 23 | { 24 | //I_TELEPORT = 0 25 | string[] tmpString = line.Replace(" ", "").Split('='); 26 | PacketNames.Add(Convert.ToUInt16(tmpString[1]), tmpString[0]); 27 | } 28 | 29 | } 30 | else 31 | { 32 | MessageBox.Show("Opcodefile not found!"); 33 | } 34 | 35 | } 36 | 37 | public static ushort GetOpcode(string name) 38 | { 39 | ushort opCode = 40 | (from val in PacketNames 41 | where val.Value.Equals(name) 42 | select val.Key).FirstOrDefault(); 43 | return opCode; 44 | } 45 | 46 | public static string GetOpcodeName(ushort opCode) 47 | { 48 | string name; 49 | 50 | if (PacketNames.ContainsKey(opCode)) 51 | { 52 | name = PacketNames[opCode]; 53 | } 54 | else 55 | { 56 | string opCodeLittleEndianHex = BitConverter.GetBytes(opCode).ToHex(); 57 | name = string.Format("0x{0}{1}", opCodeLittleEndianHex.Substring(2), 58 | opCodeLittleEndianHex.Substring(0, 2)); 59 | } 60 | 61 | return name; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY: OpcodeDLL-Projektübersicht 3 | ======================================================================== 4 | 5 | Diese OpcodeDLL-DLL wurde vom Anwendungs-Assistenten für Sie erstellt. 6 | 7 | Diese Datei bietet eine Übersicht über den Inhalt der einzelnen Dateien, aus 8 | denen Ihre OpcodeDLL-Anwendung besteht. 9 | 10 | 11 | OpcodeDLL.vcxproj 12 | Dies ist die Hauptprojektdatei für VC++-Projekte, die mit dem Anwendungs-Assistenten generiert werden. Sie enthält Informationen über die Version von Visual C++, mit der die Datei generiert wurde, sowie über die Plattformen, Konfigurationen und Projektfunktionen, die im Anwendungs-Assistenten ausgewählt wurden. 13 | 14 | OpcodeDLL.vcxproj.filters 15 | Dies ist die Filterdatei für VC++-Projekte, die mithilfe eines Anwendungs-Assistenten erstellt werden. Sie enthält Informationen über die Zuordnung zwischen den Dateien im Projekt und den Filtern. Diese Zuordnung wird in der IDE zur Darstellung der Gruppierung von Dateien mit ähnlichen Erweiterungen unter einem bestimmten Knoten verwendet (z. B. sind CPP-Dateien dem Filter "Quelldateien" zugeordnet). 16 | 17 | OpcodeDLL.cpp 18 | Dies ist die Hauptquelldatei der DLL. 19 | 20 | Diese DLL exportiert keine Symbole, Dies führt dazu, dass sie beim Buildvorgang keine LIB-Datei generiert. Wenn dieses Projekt eine Projektabhängigkeit eines anderen Projekts sein soll, müssen Sie entweder Code zum Exportieren einiger Symbole aus der DLL hinzufügen, damit eine Exportbibliothek erstellt wird, oder Sie können im Ordner "Linker" auf der Eigenschaftenseite "Allgemein" im Dialogfeld "Eigenschaftenseiten" des Projekts die Eigenschaft "Ignore Input Library" auf "Ja" festlegen. 21 | 22 | ///////////////////////////////////////////////////////////////////////////// 23 | Andere Standarddateien: 24 | 25 | StdAfx.h, StdAfx.cpp 26 | Mit diesen Dateien werden eine vorkompilierte Headerdatei (PCH) mit dem Namen OpcodeDLL.pch und eine vorkompilierte Typendatei mit dem Namen StdAfx.obj erstellt. 27 | 28 | ///////////////////////////////////////////////////////////////////////////// 29 | Weitere Hinweise: 30 | 31 | Der Anwendungs-Assistent weist Sie mit "TODO:"-Kommentaren auf Teile des 32 | Quellcodes hin, die Sie ergänzen oder anpassen sollten. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | -------------------------------------------------------------------------------- /PacketViewer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("PacketViewer")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("GoneUp")] 14 | [assembly: AssemblyProduct("PacketViewer")] 15 | [assembly: AssemblyCopyright("")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /PacketViewer/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17379 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PacketViewer.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PacketViewer.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /PacketViewer/Classes/TeraLogReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Runtime; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Controls; 10 | using PacketViewer.Network; 11 | using Tera.PacketLog; 12 | 13 | namespace PacketViewer.Classes 14 | { 15 | class TeraLogReader : IPacketInput 16 | { 17 | private FileStream fs; 18 | private BinaryReader reader; 19 | private PacketProcessor processor; 20 | 21 | public TeraLogReader(string file) 22 | { 23 | if (!File.Exists(file)) throw new Exception("File not found!"); 24 | 25 | fs = new FileStream(file, FileMode.Open); 26 | reader = new BinaryReader(fs); 27 | } 28 | 29 | public void SetProcessor(PacketProcessor pp) 30 | { 31 | processor = pp; 32 | } 33 | 34 | public void Process() 35 | { 36 | fs.Seek(0, SeekOrigin.Begin); 37 | while (fs.Position < fs.Length) 38 | { 39 | Packet_old tmpPacket; 40 | BlockType type = (BlockType)reader.ReadByte(); 41 | ushort len = reader.ReadUInt16(); 42 | fs.Seek(-2, SeekOrigin.Current); ; //turn it back, our packet_old class expects a length in the packet 43 | byte[] payload = reader.ReadBytes(len); 44 | 45 | switch (type) 46 | { 47 | case BlockType.MagicBytes: 48 | string magic = ASCIIEncoding.ASCII.GetString(payload, 2, payload.Length - 2); 49 | if (magic != "TeraConnectionLog") throw new Exception("Invalid Magic Block."); 50 | Debug.Print("found magic"); 51 | break; 52 | case BlockType.Region: 53 | string region = ASCIIEncoding.ASCII.GetString(payload, 2, payload.Length - 2); 54 | Debug.Print("region " + region); 55 | break; 56 | case BlockType.Start: 57 | Debug.Print("start"); 58 | break; 59 | case BlockType.Timestamp: 60 | //var date = LogHelper.BytesToTimeSpan(payload); 61 | //Debug.Print("time " + date.ToShortTimeString()); 62 | break; 63 | case BlockType.Client: 64 | tmpPacket = new Packet_old(Direction.CS, BitConverter.ToUInt16(payload, 2), payload, false); 65 | processor.AppendPacket(tmpPacket); 66 | break; 67 | case BlockType.Server: 68 | tmpPacket = new Packet_old(Direction.SC, BitConverter.ToUInt16(payload, 2), payload, false); 69 | processor.AppendPacket(tmpPacket); 70 | break; 71 | } 72 | } 73 | 74 | reader.Close(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /PacketViewer/Network/Capture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Threading; 5 | using System.Windows.Documents; 6 | using PacketViewer.Classes; 7 | using PacketViewer.Forms; 8 | using SharpPcap; 9 | using Tera; 10 | using Tera.Game; 11 | using Tera.PacketLog; 12 | using Tera.Sniffing; 13 | 14 | namespace PacketViewer.Network 15 | { 16 | public class Capture 17 | { 18 | private TeraSniffer sniffer; 19 | private readonly MainWindow mainWindow; 20 | private PacketLogWriter logWriter; 21 | 22 | public Capture(MainWindow mainWindow) 23 | { 24 | this.mainWindow = mainWindow; 25 | } 26 | 27 | public void Start(ServerInfo server) 28 | { 29 | Stop(); 30 | 31 | sniffer = new TeraSniffer(new List {server}); //dont want to change the external code ;) 32 | sniffer.MessageReceived += messageReceived; 33 | sniffer.NewConnection += newConnection; 34 | 35 | sniffer.Enabled = true; 36 | } 37 | 38 | public void Stop() 39 | { 40 | if (sniffer != null) 41 | { 42 | sniffer.Enabled = false; 43 | sniffer = null; 44 | } 45 | } 46 | 47 | private void newConnection(Server server) 48 | { 49 | mainWindow.SetText("New connection to " + server.Name); 50 | } 51 | 52 | private void messageReceived(Message message) 53 | { 54 | try 55 | { 56 | //Message does not contain our length, add it to see the full packet 57 | byte[] data = new byte[message.Data.Count]; 58 | Array.Copy(message.Data.Array, 0, data, 2, message.Data.Count - 2); 59 | data[0] = (byte) (((short) message.Data.Count) & 255); 60 | data[1] = (byte)(((short)message.Data.Count) >> 8); 61 | if (message.Direction == MessageDirection.ClientToServer) 62 | { 63 | Packet_old tmpPacket = new Packet_old(Direction.CS, message.OpCode, data, false); 64 | mainWindow.pp.AppendPacket(tmpPacket); 65 | } 66 | else 67 | { 68 | Packet_old tmpPacket = new Packet_old(Direction.SC, message.OpCode, data, false); 69 | mainWindow.pp.AppendPacket(tmpPacket); 70 | } 71 | 72 | if (logWriter != null) 73 | { 74 | logWriter.Append(message); 75 | } 76 | 77 | } 78 | catch (Exception ex) 79 | { 80 | 81 | mainWindow.SetText("device_OnPacketArrival failure. \n Message:" + ex); 82 | } 83 | } 84 | 85 | public void EnableLogging() 86 | { 87 | var header = new LogHeader { Region = "EU" }; 88 | logWriter = new PacketLogWriter(string.Format("{0}.TeraLog", DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss", CultureInfo.InvariantCulture)), header); 89 | } 90 | 91 | public void DisableLogging() 92 | { 93 | logWriter.Dispose(); 94 | logWriter = null; 95 | 96 | } 97 | 98 | public bool isRunning() 99 | { 100 | if (sniffer == null) return false; 101 | return sniffer.Enabled; 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /PacketViewer/Network/Lists/PacketStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace PacketViewer.Network.Lists 9 | { 10 | class PacketStream : IPacketList 11 | { 12 | private MemoryStream ms; 13 | // private BinaryReader reader; 14 | private int pointer = 0; 15 | private string tag; 16 | private static bool dbg; 17 | private object dataLock; 18 | 19 | public PacketStream(string value) 20 | { 21 | dataLock = new object(); 22 | tag = value; 23 | ms = new MemoryStream(); 24 | //reader = new BinaryReader(ms); 25 | //if (tag == "S") dbg = true; 26 | } 27 | 28 | public void Clear() 29 | { 30 | lock (dataLock) 31 | { 32 | ms = new MemoryStream(); 33 | pointer = 0; 34 | } 35 | 36 | if (dbg) Debug.Print("{0} Clear", tag); 37 | } 38 | 39 | public void Enqueue(byte[] data) 40 | { 41 | lock (dataLock) 42 | { 43 | ms.Seek(0, SeekOrigin.End); 44 | ms.Write(data, 0, data.Length); 45 | } 46 | if (dbg) Debug.Print("Enq {0} len {1}, ges {2}", tag, data.Length, ms.Length); 47 | } 48 | 49 | public byte[] GetBytes(int count) 50 | { 51 | byte[] buffer; 52 | if (count > 10000) Debug.Print("{3} Get_10k {0} count {1}, length_gesamt {2}", tag, count, ToString(), DateTime.Now.ToLongTimeString()); 53 | if (dbg) Debug.Print("Get {0} count {1}, length_gesamt {2}, pointer {3}", tag, count, ms.Length, pointer); 54 | 55 | 56 | if (count > ms.Length) 57 | { 58 | throw new Exception("DATA MISSING " + string.Format("Get {0} count {1}, length_gesamt {2}", tag, count, ms.Length)); 59 | } 60 | 61 | lock (dataLock) 62 | { 63 | buffer = new byte[count]; 64 | ms.Seek(pointer, SeekOrigin.Begin); 65 | ms.Read(buffer, 0, count); 66 | pointer += count; 67 | 68 | if (pointer == ms.Length) 69 | { 70 | //fully read, cleanup 71 | ms = new MemoryStream(); 72 | pointer = 0; 73 | } 74 | 75 | if (pointer > 0xFFFF) //64kb 76 | { 77 | 78 | } 79 | } 80 | 81 | return buffer; 82 | } 83 | 84 | public int GetLength() 85 | { 86 | return (int)ms.Length - pointer; 87 | } 88 | 89 | public bool PacketAvailable() 90 | { 91 | //peek length from buffer, check with buffer len 92 | int packetLen; 93 | lock (dataLock) 94 | { 95 | if (pointer + 2 > ms.Length) return false; 96 | packetLen = NextPacketLength(); 97 | } 98 | return (GetLength() >= packetLen); 99 | } 100 | 101 | public int NextPacketLength() 102 | { 103 | int val = BitConverter.ToUInt16(ms.GetBuffer(), pointer); 104 | return val; 105 | } 106 | 107 | public override string ToString() 108 | { 109 | StringBuilder builder = new StringBuilder(); 110 | builder.AppendLine("[PacketStream] ").AppendLine(tag); 111 | builder.AppendLine("MS Pos" + ms.Position); 112 | builder.AppendLine("MS Cap" + ms.Capacity); 113 | builder.AppendLine("GetLength " + GetLength()); 114 | builder.AppendLine("PacketAvailable " + PacketAvailable()); 115 | if (PacketAvailable()) builder.AppendLine("NextPacketLength " + NextPacketLength()); 116 | return builder.ToString(); 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /PacketViewer/Network/Lists/PacketQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace PacketViewer.Network.Lists 5 | { 6 | class PacketQueue : IPacketList 7 | { 8 | private Queue queue; 9 | private byte[] leftover; 10 | private int length; 11 | 12 | public PacketQueue() 13 | { 14 | queue = new Queue(); 15 | } 16 | 17 | public void Clear() 18 | { 19 | queue.Clear(); 20 | } 21 | 22 | public void Enqueue(byte[] data) 23 | { 24 | queue.Enqueue(data); 25 | length += data.Length; 26 | } 27 | 28 | public byte[] GetBytes(int count) 29 | { 30 | int read = 0; 31 | byte[] buffer = null; 32 | 33 | //Option A: Single complete packet in one buffer 34 | //Option B: Multiple packets in one buffer --> keep the leftover that is not requested 35 | //Option C: Packet that is in muliple Buffers --> keep leftover 36 | //Option D: Got a leftover, copy that before --> ABC 37 | 38 | 39 | if (leftover != null) 40 | { 41 | //D 42 | buffer = new byte[count]; 43 | 44 | if (leftover.Length <= count) { 45 | Array.Copy(leftover, buffer, leftover.Length); 46 | read += leftover.Length; 47 | leftover = null; 48 | } 49 | else 50 | { 51 | Array.Copy(leftover, buffer, count); 52 | byte[] newleftover = new byte[leftover.Length - count]; 53 | Array.Copy(leftover, count, newleftover, 0, leftover.Length - count); 54 | leftover = newleftover; 55 | 56 | read += count; 57 | } 58 | } 59 | 60 | while (read < count && queue.Count > 0) 61 | { 62 | byte[] dequeued = queue.Dequeue(); 63 | 64 | if (dequeued.Length + read == count) 65 | { 66 | //A 67 | if (read == 0) //complete packet in one 68 | { 69 | buffer = dequeued; 70 | } 71 | else //alrdy smth in buffer 72 | { 73 | Array.Copy(dequeued, 0, buffer, read, count - read); 74 | } 75 | read = count; 76 | } 77 | else if (dequeued.Length + read < count) 78 | { 79 | //B 80 | if (buffer == null) buffer = new byte[count]; 81 | Array.Copy(dequeued, 0, buffer, read, dequeued.Length); 82 | read += dequeued.Length; 83 | } 84 | else if (dequeued.Length + read > count) 85 | { 86 | //C 87 | if (buffer == null) buffer = new byte[count]; 88 | Array.Copy(dequeued, 0, buffer, read, count - read); 89 | 90 | leftover = new byte[(dequeued.Length + read) - count]; 91 | Array.Copy(dequeued, count - read, leftover, 0, leftover.Length); 92 | 93 | read = count; 94 | } 95 | 96 | } 97 | 98 | if (read < count) 99 | { 100 | throw new Exception("DATA MISSING"); 101 | } 102 | 103 | length -= count; 104 | return buffer; 105 | } 106 | 107 | public int GetLength() 108 | { 109 | return length; 110 | } 111 | 112 | public bool PacketAvailable() 113 | { 114 | //peek length from buffer, check with buffer len 115 | if (queue.Count == 0 && leftover == null && length < 2) return false; 116 | int packetLen = NextPacketLength(); 117 | return (GetLength() >= packetLen); 118 | } 119 | 120 | public int NextPacketLength() 121 | { 122 | if (leftover != null) return BitConverter.ToUInt16(leftover, 0); 123 | return BitConverter.ToUInt16(queue.Peek(), 0); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | 84 | # Visual Studio profiler 85 | *.psess 86 | *.vsp 87 | *.vspx 88 | *.sap 89 | 90 | # TFS 2012 Local Workspace 91 | $tf/ 92 | 93 | # Guidance Automation Toolkit 94 | *.gpState 95 | 96 | # ReSharper is a .NET coding add-in 97 | _ReSharper*/ 98 | *.[Rr]e[Ss]harper 99 | *.DotSettings.user 100 | 101 | # JustCode is a .NET coding add-in 102 | .JustCode 103 | 104 | # TeamCity is a build add-in 105 | _TeamCity* 106 | 107 | # DotCover is a Code Coverage Tool 108 | *.dotCover 109 | 110 | # NCrunch 111 | _NCrunch_* 112 | .*crunch*.local.xml 113 | nCrunchTemp_* 114 | 115 | # MightyMoose 116 | *.mm.* 117 | AutoTest.Net/ 118 | 119 | # Web workbench (sass) 120 | .sass-cache/ 121 | 122 | # Installshield output folder 123 | [Ee]xpress/ 124 | 125 | # DocProject is a documentation generator add-in 126 | DocProject/buildhelp/ 127 | DocProject/Help/*.HxT 128 | DocProject/Help/*.HxC 129 | DocProject/Help/*.hhc 130 | DocProject/Help/*.hhk 131 | DocProject/Help/*.hhp 132 | DocProject/Help/Html2 133 | DocProject/Help/html 134 | 135 | # Click-Once directory 136 | publish/ 137 | 138 | # Publish Web Output 139 | *.[Pp]ublish.xml 140 | *.azurePubxml 141 | # TODO: Comment the next line if you want to checkin your web deploy settings 142 | # but database connection strings (with potential passwords) will be unencrypted 143 | *.pubxml 144 | *.publishproj 145 | 146 | # NuGet Packages 147 | *.nupkg 148 | # The packages folder can be ignored because of Package Restore 149 | **/packages/* 150 | # except build/, which is used as an MSBuild target. 151 | !**/packages/build/ 152 | # Uncomment if necessary however generally it will be regenerated when needed 153 | #!**/packages/repositories.config 154 | 155 | # Windows Azure Build Output 156 | csx/ 157 | *.build.csdef 158 | 159 | # Windows Azure Emulator 160 | ecf/ 161 | rcf/ 162 | 163 | # Windows Store app package directory 164 | AppPackages/ 165 | BundleArtifacts/ 166 | 167 | # Visual Studio cache files 168 | # files ending in .cache can be ignored 169 | *.[Cc]ache 170 | # but keep track of directories ending in .cache 171 | !*.[Cc]ache/ 172 | 173 | # Others 174 | ClientBin/ 175 | [Ss]tyle[Cc]op.* 176 | ~$* 177 | *~ 178 | *.dbmdl 179 | *.dbproj.schemaview 180 | *.pfx 181 | *.publishsettings 182 | node_modules/ 183 | orleans.codegen.cs 184 | 185 | # RIA/Silverlight projects 186 | Generated_Code/ 187 | 188 | # Backup & report files from converting an old project file 189 | # to a newer Visual Studio version. Backup files are not needed, 190 | # because we have git ;-) 191 | _UpgradeReport_Files/ 192 | Backup*/ 193 | UpgradeLog*.XML 194 | UpgradeLog*.htm 195 | 196 | # SQL Server files 197 | *.mdf 198 | *.ldf 199 | 200 | # Business Intelligence projects 201 | *.rdl.data 202 | *.bim.layout 203 | *.bim_*.settings 204 | 205 | # Microsoft Fakes 206 | FakesAssemblies/ 207 | 208 | # GhostDoc plugin setting file 209 | *.GhostDoc.xml 210 | 211 | # Node.js Tools for Visual Studio 212 | .ntvs_analysis.dat 213 | 214 | # Visual Studio 6 build log 215 | *.plg 216 | 217 | # Visual Studio 6 workspace options file 218 | *.opt 219 | 220 | # Visual Studio LightSwitch build output 221 | **/*.HTMLClient/GeneratedArtifacts 222 | **/*.DesktopClient/GeneratedArtifacts 223 | **/*.DesktopClient/ModelManifest.xml 224 | **/*.Server/GeneratedArtifacts 225 | **/*.Server/ModelManifest.xml 226 | _Pvt_Extensions 227 | 228 | # Paket dependency manager 229 | .paket/paket.exe 230 | 231 | # FAKE - F# Make 232 | .fake/ -------------------------------------------------------------------------------- /Opcode DLL/OpcodeDLL/OpcodeDLL/OpcodeDLL.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {E7E18D39-C539-4717-A2C7-1F21C12A0233} 15 | Win32Proj 16 | OpcodeDLL 17 | 18 | 19 | 20 | DynamicLibrary 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | DynamicLibrary 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | Use 51 | Level3 52 | Disabled 53 | WIN32;_DEBUG;_WINDOWS;_USRDLL;OPCODEDLL_EXPORTS;%(PreprocessorDefinitions) 54 | 55 | 56 | Windows 57 | true 58 | 59 | 60 | 61 | 62 | Level3 63 | Use 64 | MaxSpeed 65 | true 66 | true 67 | WIN32;NDEBUG;_WINDOWS;_USRDLL;OPCODEDLL_EXPORTS;%(PreprocessorDefinitions) 68 | 69 | 70 | Windows 71 | true 72 | true 73 | true 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | false 86 | 87 | 88 | false 89 | 90 | 91 | 92 | 93 | Create 94 | Create 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /PacketViewer/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 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 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /PacketViewer/Network/PacketProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Globalization; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows.Media; 8 | 9 | using PacketViewer.Forms; 10 | using PacketViewer.Network.Lists; 11 | using Tera.PacketLog; 12 | using Tera.Sniffing.Crypt; 13 | 14 | namespace PacketViewer.Network 15 | { 16 | public class PacketProcessor 17 | { 18 | private readonly Object lockObject; 19 | 20 | public bool Initialized; 21 | public Session SecSession; 22 | 23 | public IPacketList ServerPackets; 24 | public IPacketList ClientPackets; 25 | 26 | public List Packets; 27 | 28 | 29 | private readonly MainWindow MainWindow; 30 | 31 | public PacketProcessor(MainWindow mainWindow) 32 | { 33 | lockObject = new object(); 34 | MainWindow = mainWindow; 35 | } 36 | 37 | 38 | public void Init() 39 | { 40 | SecSession = new Session(); 41 | Initialized = false; 42 | 43 | ServerPackets = new PacketStream("S"); 44 | ClientPackets = new PacketList("C"); 45 | 46 | Packets = new List(); 47 | } 48 | 49 | public void AppendServerData(byte[] data) 50 | { 51 | if (Initialized) 52 | SecSession.Encrypt(data); 53 | 54 | ServerPackets.Enqueue(data); 55 | 56 | } 57 | 58 | public void AppendClientData(byte[] data) 59 | { 60 | 61 | if (Initialized) 62 | SecSession.Decrypt(data); 63 | 64 | ClientPackets.Enqueue(data); 65 | 66 | } 67 | 68 | public void ProcessAllServerData() 69 | { 70 | if (!Initialized) return; 71 | if (ServerPackets.GetLength() > (0xFFFF)) 72 | Debug.Print("S BACKLOG " + ServerPackets.GetLength()); 73 | while (ServerPackets.PacketAvailable()) 74 | { 75 | ProcessServerData(); //aka one packet 76 | } 77 | } 78 | 79 | public void ProcessServerData() 80 | { 81 | int length = ServerPackets.NextPacketLength(); 82 | if (length == 0) throw new Exception("Server data reader is broken...."); 83 | 84 | byte[] data = ServerPackets.GetBytes(length); 85 | ushort opCode = BitConverter.ToUInt16(data, 2); 86 | Packet_old tmpPacket = new Packet_old(Direction.SC, opCode, data, false); 87 | //Debug.Print(DateTime.Now.ToLongTimeString() + " " + tmpPacket.OpName); 88 | 89 | AppendPacket(tmpPacket); 90 | } 91 | 92 | public void ProcessAllClientData() 93 | { 94 | if (!Initialized) return; 95 | if (ClientPackets.GetLength() > (0xFFFF)) Debug.Print("C BACKLOG " + ClientPackets.GetLength()); 96 | while (ClientPackets.PacketAvailable()) 97 | { 98 | ProcessClientData(); //aka one packet 99 | } 100 | } 101 | 102 | public void ProcessClientData() 103 | { 104 | int length = ClientPackets.NextPacketLength(); 105 | if (length == 0) throw new Exception("Client data reader is broken...."); 106 | 107 | byte[] data = ClientPackets.GetBytes(length); 108 | ushort opCode = BitConverter.ToUInt16(data, 2); 109 | Packet_old tmpPacket = new Packet_old(Direction.CS, opCode, data, false); 110 | 111 | AppendPacket(tmpPacket); 112 | } 113 | 114 | //Just needed a general function that also can be accessed from TeraLogReader 115 | public void AppendPacket(Packet_old tmpPacket) 116 | { 117 | //Task.Factory.StartNew(() => MainWindow.AppendPacket(Colors.WhiteSmoke, tmpPacket.ToString(), tmpPacket)); 118 | MainWindow.AppendPacket(tmpPacket); 119 | 120 | } 121 | 122 | public void TryInit() 123 | { 124 | if (Initialized) return; 125 | 126 | if (ClientPackets.GetLength() >= 256 && ServerPackets.GetLength() >= (256 + 4)) 127 | { 128 | Debug.Print("--------------Init"); 129 | ServerPackets.GetBytes(4); //first dword 130 | SecSession.ServerKey1 = ServerPackets.GetBytes(128); 131 | SecSession.ServerKey2 = ServerPackets.GetBytes(128); 132 | SecSession.ClientKey1 = ClientPackets.GetBytes(128); 133 | SecSession.ClientKey2 = ClientPackets.GetBytes(128); 134 | SecSession.Init(); 135 | 136 | Debug.Print("-----------Init2"); 137 | lock (lockObject) 138 | { 139 | //Lock tcp sniffer, we dont want any new packets while we are processing the backlog 140 | 141 | Initialized = true; 142 | byte[] tmp; 143 | if (ServerPackets.GetLength() > 0) 144 | { 145 | tmp = ServerPackets.GetBytes(ServerPackets.GetLength()); 146 | SecSession.Encrypt(tmp); 147 | ServerPackets.Enqueue(tmp); 148 | Debug.Print("#########NEXT S LEN " + ServerPackets.NextPacketLength()); 149 | } 150 | 151 | if (ClientPackets.GetLength() > 0) 152 | { 153 | tmp = ClientPackets.GetBytes(ClientPackets.GetLength()); 154 | SecSession.Decrypt(tmp); 155 | ClientPackets.Enqueue(tmp); 156 | Debug.Print("#########NEXT C LEN " + ServerPackets.NextPacketLength()); 157 | } 158 | } 159 | Debug.Print("------------Init done"); 160 | } 161 | } 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /PacketViewer/MiscFuncs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.IO; 5 | using System.Text; 6 | using System.Windows.Documents; 7 | using System.Xml; 8 | using PacketViewer.Classes; 9 | 10 | namespace PacketViewer 11 | { 12 | public static class MiscFuncs 13 | { 14 | private static readonly Random Randomizer = new Random((int)DateTime.Now.Ticks); 15 | 16 | public static Random Random() 17 | { 18 | return Randomizer; 19 | } 20 | 21 | public static int GetRoundedUtc() 22 | { 23 | // ReSharper disable PossibleLossOfFraction 24 | return (int)Math.Round((double)(GetCurrentMilliseconds() / 1000)); 25 | // ReSharper restore PossibleLossOfFraction 26 | } 27 | 28 | private static readonly DateTime StaticDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 29 | 30 | public static long GetCurrentMilliseconds() 31 | { 32 | return (long)(DateTime.UtcNow - StaticDate).TotalMilliseconds; 33 | } 34 | 35 | private static readonly string[] Baths; 36 | 37 | static MiscFuncs() 38 | { 39 | Baths = new string[256]; 40 | for (int i = 0; i < 256; i++) 41 | Baths[i] = String.Format("{0:X2}", i); 42 | } 43 | 44 | public static string ToHex(this byte[] array) 45 | { 46 | StringBuilder builder = new StringBuilder(array.Length * 2); 47 | 48 | for (int i = 0; i < array.Length; i++) 49 | builder.Append(Baths[array[i]]); 50 | 51 | return builder.ToString(); 52 | } 53 | 54 | public static string FormatHex(this byte[] data) 55 | { 56 | StringBuilder builder = new StringBuilder(data.Length * 4); 57 | 58 | int count = 0; 59 | int pass = 1; 60 | foreach (byte b in data) 61 | { 62 | if (count == 0) 63 | builder.AppendFormat("{0,-6}\t", "[" + (pass - 1) * 16 + "]"); 64 | 65 | count++; 66 | builder.Append(b.ToString("X2")); 67 | if (count == 4 || count == 8 || count == 12) 68 | builder.Append(" "); 69 | if (count == 16) 70 | { 71 | builder.Append("\t"); 72 | for (int i = (pass * count) - 16; i < (pass * count); i++) 73 | { 74 | char c = (char)data[i]; 75 | if (c > 0x1f && c < 0x80) 76 | builder.Append(c); 77 | else 78 | builder.Append("."); 79 | } 80 | builder.Append("\r\n"); 81 | count = 0; 82 | pass++; 83 | } 84 | } 85 | 86 | //Last line Hex text Adding 87 | while (count < 16) 88 | { 89 | builder.Append("\t"); 90 | count += 3; 91 | } 92 | 93 | for (int i = (pass * 16) - 16; i < (data.Length - 1); i++) 94 | { 95 | char c = (char)data[i]; 96 | if (c > 0x1f && c < 0x80) 97 | builder.Append(c); 98 | else 99 | builder.Append("."); 100 | } 101 | builder.Append("\r\n"); 102 | 103 | 104 | return builder.ToString(); 105 | } 106 | 107 | public static byte[] ToBytes(this String hexString) 108 | { 109 | try 110 | { 111 | byte[] result = new byte[hexString.Length / 2]; 112 | 113 | for (int index = 0; index < result.Length; index++) 114 | { 115 | string byteValue = hexString.Substring(index * 2, 2); 116 | result[index] = byte.Parse(byteValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture); 117 | } 118 | 119 | return result; 120 | } 121 | catch (Exception) 122 | { 123 | Console.WriteLine("Invalid hex string: {0}", hexString); 124 | throw; 125 | } 126 | } 127 | 128 | public static bool IsLuck(byte chance) 129 | { 130 | if (chance >= 100) 131 | return true; 132 | 133 | if (chance <= 0) 134 | return false; 135 | 136 | return new Random().Next(0, 100) <= chance; 137 | } 138 | 139 | public static Configuration LoadServerlistFile(string path) 140 | { 141 | /* 142 | * 143 | 144 | 145 | 146 | * */ 147 | 148 | if (File.Exists(path)) 149 | { 150 | List servers = new List(); 151 | 152 | using (XmlReader reader = XmlReader.Create(new StreamReader(path))) 153 | { 154 | reader.MoveToContent(); 155 | while (reader.Read()) 156 | { 157 | if (reader.Name == "Server") 158 | { 159 | 160 | reader.MoveToAttribute("Title"); 161 | String name = reader.Value; 162 | reader.MoveToAttribute("Ip"); 163 | String ip = reader.Value; 164 | Boolean focus = false; 165 | Boolean start = false; 166 | 167 | if (reader.MoveToAttribute("DefaultFocus")) 168 | { 169 | focus = Convert.ToBoolean(reader.Value); 170 | } 171 | if (reader.MoveToAttribute("AutoStart")) 172 | { 173 | start = Convert.ToBoolean(reader.Value); 174 | } 175 | 176 | ServerInfo info = new ServerInfo(name, ip, focus, start); 177 | 178 | servers.Add(info); 179 | } 180 | } 181 | } 182 | 183 | 184 | return new Configuration(servers); 185 | } 186 | 187 | return null; 188 | } 189 | } 190 | } -------------------------------------------------------------------------------- /PacketViewer/Network/Lists/PacketList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace PacketViewer.Network.Lists 9 | { 10 | class PacketList : IPacketList 11 | { 12 | private List list; 13 | private int length; 14 | private string tag; 15 | private static bool dbg; 16 | private object dataLock; 17 | 18 | public PacketList(string value) 19 | { 20 | dataLock = new object(); 21 | tag = value; 22 | list = new List(); 23 | if (tag == "S") dbg = true; 24 | } 25 | 26 | public void Clear() 27 | { 28 | lock (dataLock) 29 | { 30 | list.Clear(); 31 | length = 0; 32 | } 33 | 34 | if (dbg) Debug.Print("{0} Clear", tag); 35 | } 36 | 37 | public void Enqueue(byte[] data) 38 | { 39 | lock (dataLock) 40 | { 41 | list.Add(data); 42 | length += data.Length; 43 | } 44 | if (dbg) Debug.Print("Enq {0} len {1}, ges {2}", tag, data.Length, length); 45 | } 46 | 47 | public byte[] GetBytes(int count) 48 | { 49 | int read = 0; 50 | byte[] buffer = null; 51 | 52 | //Option A: Single complete packet in one buffer 53 | //Option B: Multiple packets in one buffer 54 | //Option C: Packet that is in muliple Buffers --> keep leftover 55 | //Option D: Got a leftover, copy that before --> ABC 56 | 57 | if (count > 10000) Debug.Print("Get_10k {0} count {1}, length_gesamt {2}", tag, count, ToString()); 58 | if (dbg) Debug.Print("Get {0} count {1}, length_gesamt {2}", tag, count, length); 59 | 60 | lock (dataLock) 61 | { 62 | while (read < count && list.Count > 0) 63 | { 64 | byte[] dequeued; 65 | 66 | dequeued = list[0]; 67 | list.RemoveAt(0); 68 | 69 | 70 | if (dequeued == null) continue; 71 | if (dbg) Debug.Print("Get {0} deq count {1}, read {2}", tag, dequeued.Length, read); 72 | 73 | if (dequeued.Length + read == count) 74 | { 75 | //A 76 | if (read == 0) //complete packet in one 77 | { 78 | buffer = dequeued; 79 | } 80 | else //alrdy smth in buffer 81 | { 82 | Array.Copy(dequeued, 0, buffer, read, count - read); 83 | } 84 | read = count; 85 | if (dbg) Debug.Print(tag + "_A"); 86 | } 87 | else if (dequeued.Length + read < count) 88 | { 89 | //B 90 | if (buffer == null) buffer = new byte[count]; 91 | Array.Copy(dequeued, 0, buffer, read, dequeued.Length); 92 | read += dequeued.Length; 93 | if (dbg) Debug.Print(tag + "_B read now " + read); 94 | } 95 | else if (dequeued.Length + read > count) 96 | { 97 | //C 98 | if (buffer == null) buffer = new byte[count]; 99 | Array.Copy(dequeued, 0, buffer, read, count - read); 100 | 101 | //copy leftover back into first postition, next run will just get is as a normal part 102 | byte[] leftover = new byte[(dequeued.Length + read) - count]; 103 | Array.Copy(dequeued, count - read, leftover, 0, leftover.Length); 104 | list.Insert(0, leftover); 105 | read = count; 106 | if (dbg) Debug.Print(tag + "_C buffer size {0}, leftover size {1}, next packet len {2}", buffer.Length, leftover.Length, NextPacketLength()); 107 | } 108 | 109 | } 110 | 111 | if (read < count) 112 | { 113 | throw new Exception("DATA MISSING " + string.Format("Get {0} count {1}, length_gesamt {2} read {3}", tag, count, length, read)); 114 | } 115 | 116 | length -= count; 117 | } 118 | return buffer; 119 | } 120 | 121 | public int GetLength() 122 | { 123 | return length; 124 | } 125 | 126 | public bool PacketAvailable() 127 | { 128 | //peek length from buffer, check with buffer len 129 | int packetLen; 130 | lock (dataLock) 131 | { 132 | if (list.Count == 0 || length < 2) return false; 133 | packetLen = NextPacketLength(); 134 | } 135 | return (GetLength() >= packetLen); 136 | } 137 | 138 | public int NextPacketLength() 139 | { 140 | var tmp = new MemoryStream(); 141 | for (int i = 0; i < list.Count; i++) 142 | { 143 | if (list[i] == null) continue; 144 | if (tmp.Length >= 2) 145 | { 146 | /* 147 | if (BitConverter.ToUInt16(tmp.GetBuffer(), 0) == 0) 148 | { 149 | i = 0; //bugged packet, drop it and hope that the next is readable again 150 | tmp = new MemoryStream(); 151 | list.RemoveAt(0); 152 | continue; 153 | } 154 | */ 155 | break; 156 | } 157 | tmp.Write(list[i], 0, list[i].Count()); 158 | } 159 | return BitConverter.ToUInt16(tmp.GetBuffer(), 0); 160 | } 161 | 162 | public override string ToString() 163 | { 164 | StringBuilder builder = new StringBuilder(); 165 | builder.AppendLine("[PacketList] ").AppendLine(tag); 166 | builder.AppendLine("List.Count " + list.Count); 167 | builder.AppendLine("GetLength " + GetLength()); 168 | builder.AppendLine("PacketAvailable " + PacketAvailable()); 169 | if (PacketAvailable()) builder.AppendLine("NextPacketLength " + NextPacketLength()); 170 | return builder.ToString(); 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /PacketViewer/PacketViewer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C6B79B46-E598-416F-B56E-5DAE09B3EF06} 8 | WinExe 9 | Properties 10 | PacketViewer 11 | PacketViewer 12 | v4.5 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | ..\build\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | ..\build\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | icon.ico 38 | 39 | 40 | PacketViewer.Program 41 | 42 | 43 | 44 | Libs\PacketDotNet.dll 45 | False 46 | 47 | 48 | Libs\SharpPcap.dll 49 | False 50 | 51 | 52 | 53 | 54 | 55 | 4.0 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | MSBuild:Compile 64 | Designer 65 | 66 | 67 | MSBuild:Compile 68 | Designer 69 | 70 | 71 | App.xaml 72 | Code 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | MainWindow.xaml 83 | Code 84 | 85 | 86 | MSBuild:Compile 87 | Designer 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | Code 102 | 103 | 104 | True 105 | True 106 | Resources.resx 107 | 108 | 109 | True 110 | Settings.settings 111 | True 112 | 113 | 114 | ResXFileCodeGenerator 115 | Resources.Designer.cs 116 | 117 | 118 | SettingsSingleFileGenerator 119 | Settings.Designer.cs 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | {EE476C7C-2942-4BA4-AB47-7ADBE65635FD} 129 | Tera.Core 130 | False 131 | 132 | 133 | {66BB1685-8FF5-4431-B77F-7F80C92A5DA4} 134 | Tera.Sniffing 135 | False 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | Always 151 | 152 | 153 | 154 | 161 | -------------------------------------------------------------------------------- /Tera.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PacketViewer", "PacketViewer\PacketViewer.csproj", "{C6B79B46-E598-416F-B56E-5DAE09B3EF06}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TeraDamageMeter", "TeraDamageMeter", "{166AE990-21DE-4AE3-82B5-85052A7E2193}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tera.Sniffer", "external\TDM\Tera.Sniffer\Tera.Sniffer.csproj", "{AB53A885-EA95-4ABC-8D65-32E8E80485B5}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tera.Core", "external\TDM\Tera.Core\Tera.Core.csproj", "{EE476C7C-2942-4BA4-AB47-7ADBE65635FD}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{60571443-038A-4337-9ED2-D4164D35B0F3}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkSniffer", "external\TDM\NetworkSniffer\NetworkSniffer.csproj", "{5B431143-1A77-44FF-8BC3-926FEC8AD97C}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tera.DamageMeter", "external\TDM\Tera.DamageMeter\Tera.DamageMeter.csproj", "{9F95A8E5-0D27-4F16-A3F3-A1EC130A85EC}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tera.Data", "external\TDM\Tera.Data\Tera.Data.csproj", "{4B6AA9BD-CEC2-4AA6-B35A-1ACB2FA7767B}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tera.Sniffing", "external\TDM\Tera.Sniffing\Tera.Sniffing.csproj", "{66BB1685-8FF5-4431-B77F-7F80C92A5DA4}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tera.DamageMeter.WPF", "external\TDM\Tera.DamageMeter.WPF\Tera.DamageMeter.WPF.csproj", "{C8FF7566-3037-4F08-BAB6-98D7388DC852}" 23 | EndProject 24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tera.DamageMeter.Core", "external\TDM\Tera.DamageMeter.Core\Tera.DamageMeter.Core.csproj", "{D1ED4752-F2FC-44C3-97B2-580BC79F4AF1}" 25 | EndProject 26 | Global 27 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 28 | Debug|Any CPU = Debug|Any CPU 29 | Debug|x64 = Debug|x64 30 | Release|Any CPU = Release|Any CPU 31 | Release|x64 = Release|x64 32 | EndGlobalSection 33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 34 | {C6B79B46-E598-416F-B56E-5DAE09B3EF06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {C6B79B46-E598-416F-B56E-5DAE09B3EF06}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {C6B79B46-E598-416F-B56E-5DAE09B3EF06}.Debug|x64.ActiveCfg = Debug|Any CPU 37 | {C6B79B46-E598-416F-B56E-5DAE09B3EF06}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {C6B79B46-E598-416F-B56E-5DAE09B3EF06}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {C6B79B46-E598-416F-B56E-5DAE09B3EF06}.Release|x64.ActiveCfg = Release|Any CPU 40 | {AB53A885-EA95-4ABC-8D65-32E8E80485B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {AB53A885-EA95-4ABC-8D65-32E8E80485B5}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {AB53A885-EA95-4ABC-8D65-32E8E80485B5}.Debug|x64.ActiveCfg = Debug|Any CPU 43 | {AB53A885-EA95-4ABC-8D65-32E8E80485B5}.Release|Any CPU.ActiveCfg = Release|Any CPU 44 | {AB53A885-EA95-4ABC-8D65-32E8E80485B5}.Release|Any CPU.Build.0 = Release|Any CPU 45 | {AB53A885-EA95-4ABC-8D65-32E8E80485B5}.Release|x64.ActiveCfg = Release|Any CPU 46 | {EE476C7C-2942-4BA4-AB47-7ADBE65635FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {EE476C7C-2942-4BA4-AB47-7ADBE65635FD}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {EE476C7C-2942-4BA4-AB47-7ADBE65635FD}.Debug|x64.ActiveCfg = Debug|Any CPU 49 | {EE476C7C-2942-4BA4-AB47-7ADBE65635FD}.Release|Any CPU.ActiveCfg = Release|Any CPU 50 | {EE476C7C-2942-4BA4-AB47-7ADBE65635FD}.Release|Any CPU.Build.0 = Release|Any CPU 51 | {EE476C7C-2942-4BA4-AB47-7ADBE65635FD}.Release|x64.ActiveCfg = Release|Any CPU 52 | {5B431143-1A77-44FF-8BC3-926FEC8AD97C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {5B431143-1A77-44FF-8BC3-926FEC8AD97C}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {5B431143-1A77-44FF-8BC3-926FEC8AD97C}.Debug|x64.ActiveCfg = Debug|Any CPU 55 | {5B431143-1A77-44FF-8BC3-926FEC8AD97C}.Release|Any CPU.ActiveCfg = Release|Any CPU 56 | {5B431143-1A77-44FF-8BC3-926FEC8AD97C}.Release|Any CPU.Build.0 = Release|Any CPU 57 | {5B431143-1A77-44FF-8BC3-926FEC8AD97C}.Release|x64.ActiveCfg = Release|Any CPU 58 | {9F95A8E5-0D27-4F16-A3F3-A1EC130A85EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 59 | {9F95A8E5-0D27-4F16-A3F3-A1EC130A85EC}.Debug|Any CPU.Build.0 = Debug|Any CPU 60 | {9F95A8E5-0D27-4F16-A3F3-A1EC130A85EC}.Debug|x64.ActiveCfg = Debug|Any CPU 61 | {9F95A8E5-0D27-4F16-A3F3-A1EC130A85EC}.Release|Any CPU.ActiveCfg = Release|Any CPU 62 | {9F95A8E5-0D27-4F16-A3F3-A1EC130A85EC}.Release|Any CPU.Build.0 = Release|Any CPU 63 | {9F95A8E5-0D27-4F16-A3F3-A1EC130A85EC}.Release|x64.ActiveCfg = Release|Any CPU 64 | {4B6AA9BD-CEC2-4AA6-B35A-1ACB2FA7767B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {4B6AA9BD-CEC2-4AA6-B35A-1ACB2FA7767B}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {4B6AA9BD-CEC2-4AA6-B35A-1ACB2FA7767B}.Debug|x64.ActiveCfg = Debug|Any CPU 67 | {4B6AA9BD-CEC2-4AA6-B35A-1ACB2FA7767B}.Release|Any CPU.ActiveCfg = Release|Any CPU 68 | {4B6AA9BD-CEC2-4AA6-B35A-1ACB2FA7767B}.Release|Any CPU.Build.0 = Release|Any CPU 69 | {4B6AA9BD-CEC2-4AA6-B35A-1ACB2FA7767B}.Release|x64.ActiveCfg = Release|Any CPU 70 | {66BB1685-8FF5-4431-B77F-7F80C92A5DA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 71 | {66BB1685-8FF5-4431-B77F-7F80C92A5DA4}.Debug|Any CPU.Build.0 = Debug|Any CPU 72 | {66BB1685-8FF5-4431-B77F-7F80C92A5DA4}.Debug|x64.ActiveCfg = Debug|Any CPU 73 | {66BB1685-8FF5-4431-B77F-7F80C92A5DA4}.Release|Any CPU.ActiveCfg = Release|Any CPU 74 | {66BB1685-8FF5-4431-B77F-7F80C92A5DA4}.Release|Any CPU.Build.0 = Release|Any CPU 75 | {66BB1685-8FF5-4431-B77F-7F80C92A5DA4}.Release|x64.ActiveCfg = Release|Any CPU 76 | {C8FF7566-3037-4F08-BAB6-98D7388DC852}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 77 | {C8FF7566-3037-4F08-BAB6-98D7388DC852}.Debug|Any CPU.Build.0 = Debug|Any CPU 78 | {C8FF7566-3037-4F08-BAB6-98D7388DC852}.Debug|x64.ActiveCfg = Debug|Any CPU 79 | {C8FF7566-3037-4F08-BAB6-98D7388DC852}.Release|Any CPU.ActiveCfg = Release|Any CPU 80 | {C8FF7566-3037-4F08-BAB6-98D7388DC852}.Release|Any CPU.Build.0 = Release|Any CPU 81 | {C8FF7566-3037-4F08-BAB6-98D7388DC852}.Release|x64.ActiveCfg = Release|Any CPU 82 | {D1ED4752-F2FC-44C3-97B2-580BC79F4AF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 83 | {D1ED4752-F2FC-44C3-97B2-580BC79F4AF1}.Debug|Any CPU.Build.0 = Debug|Any CPU 84 | {D1ED4752-F2FC-44C3-97B2-580BC79F4AF1}.Debug|x64.ActiveCfg = Debug|Any CPU 85 | {D1ED4752-F2FC-44C3-97B2-580BC79F4AF1}.Release|Any CPU.ActiveCfg = Release|Any CPU 86 | {D1ED4752-F2FC-44C3-97B2-580BC79F4AF1}.Release|Any CPU.Build.0 = Release|Any CPU 87 | {D1ED4752-F2FC-44C3-97B2-580BC79F4AF1}.Release|x64.ActiveCfg = Release|Any CPU 88 | EndGlobalSection 89 | GlobalSection(SolutionProperties) = preSolution 90 | HideSolutionNode = FALSE 91 | EndGlobalSection 92 | GlobalSection(NestedProjects) = preSolution 93 | {AB53A885-EA95-4ABC-8D65-32E8E80485B5} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 94 | {EE476C7C-2942-4BA4-AB47-7ADBE65635FD} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 95 | {60571443-038A-4337-9ED2-D4164D35B0F3} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 96 | {5B431143-1A77-44FF-8BC3-926FEC8AD97C} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 97 | {9F95A8E5-0D27-4F16-A3F3-A1EC130A85EC} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 98 | {4B6AA9BD-CEC2-4AA6-B35A-1ACB2FA7767B} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 99 | {66BB1685-8FF5-4431-B77F-7F80C92A5DA4} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 100 | {C8FF7566-3037-4F08-BAB6-98D7388DC852} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 101 | {D1ED4752-F2FC-44C3-97B2-580BC79F4AF1} = {166AE990-21DE-4AE3-82B5-85052A7E2193} 102 | EndGlobalSection 103 | EndGlobal 104 | -------------------------------------------------------------------------------- /PacketViewer/Forms/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 55 | 56 |