├── Dockerfile
├── .nuget
├── NuGet.exe
├── NuGet.Config
└── NuGet.targets
├── harhar
├── packages.config
├── App.config
├── AbstractBar.cs
├── HarharLog.cs
├── AnimatedBar.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── app.manifest
├── LICENSE
├── SwayBar.cs
├── harhar.csproj
└── Program.cs
├── README.md
├── harhar.sln
├── LICENSE
├── .gitattributes
└── .gitignore
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mono:3.10-onbuild
2 | CMD [ "mono", "./harhar.exe" ]
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/acastaner/harhar/HEAD/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/harhar/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Humble Avalanche Replayer of HTTP Archives
2 | ===========================================
3 |
4 | Or "Harhar", as we call it. Generate a HTTP Archive (.har) file using your browser, and replay the content at high volumes using Spirent Avalanche. Works on Windows and Linux (Mono).
5 |
6 | Build status
7 | ============
8 |
9 | [](https://ci.appveyor.com/project/acastaner/harhar)
10 |
--------------------------------------------------------------------------------
/harhar/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/harhar/AbstractBar.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 Harhar
8 | {
9 | abstract class AbstractBar
10 | {
11 | public AbstractBar()
12 | {
13 |
14 | }
15 |
16 | ///
17 | /// Prints a simple message
18 | ///
19 | /// Message to print
20 | public void PrintMessage(string msg)
21 | {
22 | Console.WriteLine(msg);
23 | }
24 |
25 | public abstract void Step();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/harhar/HarharLog.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 |
8 | namespace Harhar
9 | {
10 | public class HarharLog
11 | {
12 | public string FilePath { get; set; }
13 |
14 | public HarharLog(string filePath)
15 | {
16 | FilePath = filePath;
17 | }
18 |
19 | public void AppendLine(string value, HarharLogMessageTypes messageType)
20 | {
21 | var file = File.AppendText(FilePath);
22 | file.WriteLine("{0} [{1}] : {2}", DateTime.Now.ToString(), messageType.ToString(), value);
23 | file.Close();
24 | }
25 | }
26 | public enum HarharLogMessageTypes
27 | {
28 | Info,
29 | Warning,
30 | Error,
31 | Fatal
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/harhar/AnimatedBar.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 Harhar
8 | {
9 | class AnimatedBar : AbstractBar
10 | {
11 | List animation;
12 | int counter;
13 | public AnimatedBar()
14 | : base()
15 | {
16 | this.animation = new List { "/", "-", @"\", "|" };
17 | this.counter = 0;
18 | }
19 |
20 | ///
21 | /// Prints the character found in the animation according to the current index
22 | ///
23 | public override void Step()
24 | {
25 | Console.Write(this.animation[this.counter] + "\b");
26 | this.counter++;
27 | if (this.counter == this.animation.Count)
28 | this.counter = 0;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/harhar.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "harhar", "harhar\harhar.csproj", "{9710384D-A984-4FD3-AA74-D2DD61313E0D}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{B3F86AE6-E007-4FDE-836A-64955FDDE47C}"
9 | ProjectSection(SolutionItems) = preProject
10 | .nuget\NuGet.Config = .nuget\NuGet.Config
11 | .nuget\NuGet.exe = .nuget\NuGet.exe
12 | .nuget\NuGet.targets = .nuget\NuGet.targets
13 | EndProjectSection
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {9710384D-A984-4FD3-AA74-D2DD61313E0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {9710384D-A984-4FD3-AA74-D2DD61313E0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {9710384D-A984-4FD3-AA74-D2DD61313E0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {9710384D-A984-4FD3-AA74-D2DD61313E0D}.Release|Any CPU.Build.0 = Release|Any CPU
25 | EndGlobalSection
26 | GlobalSection(SolutionProperties) = preSolution
27 | HideSolutionNode = FALSE
28 | EndGlobalSection
29 | EndGlobal
30 |
--------------------------------------------------------------------------------
/harhar/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Harhar")]
9 | [assembly: AssemblyDescription("Humble Avalanche Replayer of HTTP Archives")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Arnaud Castaner")]
12 | [assembly: AssemblyProduct("HarHAR")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("59f4af48-2056-40ec-9554-6d2da5a5c4a2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.3.2")]
36 | [assembly: AssemblyFileVersion("1.0.3.2")]
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | HarNet License
2 | ================================================================================
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2014 Arnaud Castaner
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
25 | Newtonsoft JSON.NET License
26 | ================================================================================
27 | The MIT License (MIT)
28 |
29 | Copyright (c) 2007 James Newton-King
30 |
31 | Permission is hereby granted, free of charge, to any person obtaining a copy
32 | of this software and associated documentation files (the "Software"), to deal
33 | in the Software without restriction, including without limitation the rights
34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35 | copies of the Software, and to permit persons to whom the Software is
36 | furnished to do so, subject to the following conditions:
37 |
38 | The above copyright notice and this permission notice shall be included in all
39 | copies or substantial portions of the Software.
40 |
41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47 | SOFTWARE.
48 |
49 | NodaTime License
50 | ================================================================================
51 | Apache License, Version 2.0:
52 | http://www.apache.org/licenses/LICENSE-2.0
53 |
--------------------------------------------------------------------------------
/harhar/LICENSE:
--------------------------------------------------------------------------------
1 | HarNet License
2 | ================================================================================
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2014 Arnaud Castaner
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
25 | Newtonsoft JSON.NET License
26 | ================================================================================
27 | The MIT License (MIT)
28 |
29 | Copyright (c) 2007 James Newton-King
30 |
31 | Permission is hereby granted, free of charge, to any person obtaining a copy
32 | of this software and associated documentation files (the "Software"), to deal
33 | in the Software without restriction, including without limitation the rights
34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35 | copies of the Software, and to permit persons to whom the Software is
36 | furnished to do so, subject to the following conditions:
37 |
38 | The above copyright notice and this permission notice shall be included in all
39 | copies or substantial portions of the Software.
40 |
41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47 | SOFTWARE.
48 |
49 | NodaTime License
50 | ================================================================================
51 | Apache License, Version 2.0:
52 | http://www.apache.org/licenses/LICENSE-2.0
53 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/harhar/SwayBar.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 Harhar
8 | {
9 | class SwayBar : AbstractBar
10 | {
11 | string bar;
12 | string pointer;
13 | string blankPointer;
14 | int counter;
15 | direction currdir;
16 | enum direction { right, left };
17 | public SwayBar()
18 | : base()
19 | {
20 | this.bar = "| |";
21 | this.pointer = "***";
22 | this.blankPointer = this.BlankPointer();
23 | this.currdir = direction.right;
24 | this.counter = 1;
25 | }
26 |
27 | ///
28 | /// sets the atribute blankPointer with a empty string the same length that the pointer
29 | ///
30 | /// A string filled with space characters
31 | private string BlankPointer()
32 | {
33 | StringBuilder blank = new StringBuilder();
34 | for (int cont = 0; cont < this.pointer.Length; cont++)
35 | blank.Append(" ");
36 | return blank.ToString();
37 | }
38 |
39 | ///
40 | /// reset the bar to its original state
41 | ///
42 | private void ClearBar()
43 | {
44 | this.bar = this.bar.Replace(this.pointer, this.blankPointer);
45 | }
46 |
47 | ///
48 | /// remove the previous pointer and place it in a new possition
49 | ///
50 | /// start index
51 | /// end index
52 | private void PlacePointer(int start, int end)
53 | {
54 | this.ClearBar();
55 | this.bar = this.bar.Remove(start, end);
56 | this.bar = this.bar.Insert(start, this.pointer);
57 | }
58 |
59 | ///
60 | /// prints the progress bar acorrding to pointers and current direction
61 | ///
62 | public override void Step()
63 | {
64 | if (this.currdir == direction.right)
65 | {
66 | this.PlacePointer(counter, this.pointer.Length);
67 | this.counter++;
68 | if (this.counter + this.pointer.Length == this.bar.Length)
69 | this.currdir = direction.left;
70 | }
71 | else
72 | {
73 | this.PlacePointer(counter - this.pointer.Length, this.pointer.Length);
74 | this.counter--;
75 | if (this.counter == this.pointer.Length)
76 | this.currdir = direction.right;
77 | }
78 | Console.Write(this.bar + "\r");
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/harhar/Properties/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
52 |
--------------------------------------------------------------------------------
/.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 Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 |
--------------------------------------------------------------------------------
/harhar/harhar.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {9710384D-A984-4FD3-AA74-D2DD61313E0D}
8 | Exe
9 | Properties
10 | Harhar
11 | harhar
12 | v4.5
13 | 512
14 | false
15 |
16 | ..\
17 | true
18 | E:\Documents\Dropbox\Spirent\harhar.alarash.net\files\alarash.net\harhar\1.0.3\
19 | true
20 | Disk
21 | false
22 | Foreground
23 | 7
24 | Days
25 | false
26 | false
27 | true
28 | publish.htm
29 | 5
30 | 1.0.0.%2a
31 | false
32 | true
33 | true
34 |
35 |
36 | AnyCPU
37 | true
38 | full
39 | false
40 | bin\Debug\
41 | DEBUG;TRACE
42 | prompt
43 | 4
44 | false
45 |
46 |
47 | AnyCPU
48 | pdbonly
49 | true
50 | bin\Release\
51 | TRACE
52 | prompt
53 | 4
54 | false
55 | true
56 |
57 |
58 | 9803E8FBB2986ADC098FFA094869382F62D24BD8
59 |
60 |
61 | HarA_TemporaryKey.pfx
62 |
63 |
64 | true
65 |
66 |
67 | false
68 |
69 |
70 | LocalIntranet
71 |
72 |
73 | Properties\app.manifest
74 |
75 |
76 | Harhar.Program
77 |
78 |
79 |
80 | False
81 | ..\packages\HarNet.0.9.0.13\bin\Release\HarNet.dll
82 |
83 |
84 | False
85 | ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 | PreserveNewest
108 |
109 |
110 | Designer
111 |
112 |
113 |
114 |
115 |
116 | False
117 | Microsoft .NET Framework 4.5 %28x86 and x64%29
118 | true
119 |
120 |
121 | False
122 | .NET Framework 3.5 SP1 Client Profile
123 | false
124 |
125 |
126 | False
127 | .NET Framework 3.5 SP1
128 | false
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
140 |
141 |
142 |
143 |
150 |
--------------------------------------------------------------------------------
/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
41 |
42 |
43 |
44 | $(MSBuildProjectDirectory)\packages.config
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | $(NuGetToolsPath)\NuGet.exe
51 | @(PackageSource)
52 |
53 | "$(NuGetExePath)"
54 | mono --runtime=v4.0.30319 "$(NuGetExePath)"
55 |
56 | $(TargetDir.Trim('\\'))
57 |
58 | -RequireConsent
59 | -NonInteractive
60 |
61 | "$(SolutionDir) "
62 | "$(SolutionDir)"
63 |
64 |
65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
67 |
68 |
69 |
70 | RestorePackages;
71 | $(BuildDependsOn);
72 |
73 |
74 |
75 |
76 | $(BuildDependsOn);
77 | BuildPackage;
78 |
79 |
80 |
81 |
82 |
83 |
84 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
99 |
100 |
103 |
104 |
105 |
106 |
108 |
109 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/harhar/Program.cs:
--------------------------------------------------------------------------------
1 | using Harnet;
2 | using Harnet.Net;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text.RegularExpressions;
8 | using System.Threading.Tasks;
9 |
10 | namespace Harhar
11 | {
12 | class Program
13 | {
14 | // Used to track unknown Media Types that were met during parsing
15 | static List unknownMediaTypes = new List();
16 | // Used to track connection Ids that were used (determine level 1 or level 2 URLs)
17 | static List usedConnectionIds = new List();
18 | static int errorCount = 0;
19 | static HarharLog harharLog;
20 |
21 | static List urls = new List();
22 | static List actionList = new List();
23 |
24 | static void Main(string[] args)
25 | {
26 | string[] filePaths = {};
27 | // Check for command-line arguments
28 | if (args.Length != 0)
29 | {
30 | string checkForPath = args[0];
31 | if (Directory.Exists(checkForPath))
32 | filePaths = Directory.GetFiles(checkForPath, "*.har");
33 | else if (File.Exists(checkForPath))
34 | filePaths = new string[] { checkForPath };
35 | else
36 | Console.WriteLine("Error - Cannot find specified HAR file or no files were found in provided directory.");
37 | Console.WriteLine("Usage: harhar.exe ");
38 | }
39 | // If no command-line arguments, look for .har files in current directory
40 | else
41 | {
42 | filePaths = Directory.GetFiles(@".", "*.har");
43 | }
44 |
45 | if (filePaths.Length >= 1)
46 | {
47 | DateTime date = DateTime.Now;
48 | string formattedDate = date.Month.ToString() + "-" + date.Day.ToString() + "-" + date.Year.ToString() + "_" + date.Hour.ToString() + "-" + date.Minute.ToString() + "-" + date.Second.ToString();
49 | string workingDirectory = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + formattedDate + Path.DirectorySeparatorChar;
50 | if (!Directory.Exists(workingDirectory))
51 | Directory.CreateDirectory(workingDirectory);
52 |
53 | harharLog = new HarharLog(workingDirectory + "run.log");
54 |
55 | foreach (string path in filePaths)
56 | {
57 | HandleHarFile(workingDirectory, path);
58 | }
59 | // If we encounter unknown MIME Types, write a file with their type
60 | if (unknownMediaTypes.Count > 0)
61 | {
62 | string fileName = "UnknownMedia.log";
63 | WriteUnknownMimeTypesToFile(workingDirectory + fileName);
64 | Console.WriteLine("Unknown Media Types were found in this archive. Please send debug file " + fileName + " to arnaud.castaner@spirent.com.");
65 | }
66 | }
67 | else
68 | {
69 | Console.WriteLine("No HAR file found within the current directory. Please specify a file or directory holding files.");
70 | Console.WriteLine("Example: harhar.exe ");
71 | }
72 |
73 | Console.Write("Parsing complete. Press any key to exit.");
74 | Console.ReadKey();
75 | }
76 |
77 | private static void WriteUnknownMimeTypesToFile(string path)
78 | {
79 | File.WriteAllLines(path, unknownMediaTypes.ToArray());
80 | }
81 |
82 | private static void HandleHarFile(string workingDirectory, string filePath)
83 | {
84 | string content = File.ReadAllText(filePath);
85 | Log datLog = HarConverter.ImportHarContent(content);
86 | Console.WriteLine("Total Response size: " + datLog.CumulatedResponseSize + " bytes (headers: " + datLog.CumulatedResponseHeaderSize + " ; bodies: " + datLog.CumulatedResponseBodySize + " )");
87 | Console.WriteLine("Total Request size: " + datLog.CumulatedRequestSize + " bytes (headers: " + datLog.CumulatedRequestHeaderSize + " ; bodies: " + datLog.CumulatedRequestBodySize + " )");
88 | Console.WriteLine("Found " + datLog.Entries.Count + " entries in log.");
89 | HandleLogFile(datLog, workingDirectory, Path.GetFileName(filePath));
90 | }
91 |
92 | private static async Task HandleLogEntry(Entry entry, string workingDirectory, bool firstAction)
93 | {
94 | Response resp = entry.Response;
95 | Request req = entry.Request;
96 |
97 | // If there's no file in the URL (e.g. www.fsf.org), we force it to index.html
98 | // We also have to add the hostname so that it's stored under the right directory (e.g. www.fsg.org\index.html) as is done for the other files
99 | string fileName;
100 | if (req.GetFileName() != null)
101 | fileName = req.GetFileName();
102 | else
103 | fileName = "index.html";
104 |
105 |
106 | // If status code is < 400 it's 200 or 300, ie: not an error
107 | if (resp.Status < 400)
108 | {
109 | // We keep the whole URL to build complete file path (directory + file name) but need to remove special characters and query strings not supported by the file system
110 | // First let's get the Request URL and filename stripped of anything special (people like to put specials characters such as ":" in their URLs)
111 | string cleanUrl = GetCleanUrl(req);
112 | string cleanFileName = EscapeSpecialCharacters(fileName);
113 |
114 | // Remove the filename from the URL since we save it separately
115 | // Since we already cleaned the URL of query parameters, we can just remove anything after the last /
116 | cleanUrl = StripFileNameFromUrl(cleanUrl);
117 | string filePathString = workingDirectory + cleanUrl + Path.DirectorySeparatorChar + cleanFileName;
118 |
119 | // Windows as a limitation of 248 on path name and 260 for FQP so we truncate at 248
120 | if (filePathString.Length >= 248)
121 | {
122 | filePathString = filePathString.Substring(0, 248);
123 | string pathLenghtWarning = "Path was too long and had to be truncated for " + filePathString;
124 | errorCount++;
125 | harharLog.AppendLine(pathLenghtWarning, HarharLogMessageTypes.Warning);
126 | }
127 |
128 | string storingDirectory = Path.GetDirectoryName(filePathString);
129 | // Sometimes the *directory* won't exist, but there will be an extensionless file (e.g.: "rsp") of the same name
130 | // When this happens, it passes the check below, but fails when trying to create directory so we also need a catch
131 | if (!Directory.Exists(storingDirectory))
132 | {
133 | try
134 | {
135 | Directory.CreateDirectory(storingDirectory);
136 | }
137 | catch (Exception ex)
138 | {
139 | harharLog.AppendLine("Could not create directory " + storingDirectory + ". Caught this error: " + ex.Message, HarharLogMessageTypes.Fatal);
140 | errorCount++;
141 | }
142 | }
143 |
144 | WriteFile(filePathString, resp);
145 | actionList.Add(AddAction(entry, firstAction));
146 | // If this was the first action, it's no longer the case at this point
147 | firstAction = false;
148 | urls.Add(req.Url);
149 | }
150 | File.WriteAllLines(workingDirectory + "urls.txt", urls.ToArray());
151 | File.WriteAllLines(workingDirectory + "action_list.txt", actionList.ToArray());
152 | }
153 |
154 | private async static void HandleLogFile(Log harLog, string workingDirectory, string logFileName)
155 | {
156 | workingDirectory += logFileName + Path.DirectorySeparatorChar;
157 |
158 | actionList.Add("### Generated on " + DateTime.Now + " by HarHar tool ###");
159 |
160 | Console.WriteLine("Creating working directory at " + workingDirectory);
161 | Directory.CreateDirectory(workingDirectory);
162 |
163 | // Used for Avalanche Action List
164 | bool firstAction = true;
165 |
166 | // Setup progress bar
167 | AbstractBar bar = new SwayBar();
168 | int end = harLog.Entries.Count;
169 |
170 | bar.PrintMessage("Parsing HAR file...");
171 | foreach (Entry entry in harLog.Entries)
172 | {
173 | await HandleLogEntry(entry, workingDirectory, firstAction);
174 | bar.Step();
175 | }
176 | bar.PrintMessage("Parsing completed.");
177 | }
178 |
179 | ///
180 | /// Writes the Avalanche actions for the Action List
181 | ///
182 | ///
183 | ///
184 | ///
185 | private static string AddAction(Entry entry, bool firstAction)
186 | {
187 | string action = "";
188 |
189 | // First action must always be level 1
190 | if (firstAction)
191 | {
192 | action += "1 ";
193 | usedConnectionIds.Add(entry.Connection);
194 | }
195 | // If we have already seen that connection before, means it's a level 1 action (Avalanche won't open a new connection)
196 | else if (usedConnectionIds.Contains(entry.Connection))
197 | {
198 | action += "1 ";
199 | }
200 | // If we have never seen this connection before, means Avalanche can open a new connection for this action (level 2 action)
201 | else
202 | {
203 | action += "2 ";
204 | usedConnectionIds.Add(entry.Connection);
205 | }
206 |
207 | // Strip HTTP 1.1 headers that Avalanche adds automatically
208 | entry.Request.Headers.Remove("Host");
209 | entry.Request.Headers.Remove("Path");
210 | entry.Request.Headers.Remove("Version");
211 | entry.Request.Headers.Remove("Scheme");
212 | entry.Request.Headers.Remove("Method");
213 | entry.Request.Headers.Remove("Connection");
214 |
215 | // Chrome adds this in SSL
216 | entry.Request.Headers.Remove(":host");
217 | entry.Request.Headers.Remove(":path");
218 | entry.Request.Headers.Remove(":version");
219 | entry.Request.Headers.Remove(":scheme");
220 | entry.Request.Headers.Remove(":method");
221 |
222 | action += entry.Request.Method + " " + entry.Request.Url;
223 |
224 | if (entry.Request.Headers.Count >= 1)
225 | {
226 | foreach (var pair in entry.Request.Headers)
227 | {
228 | for (int i = 0; i < pair.Value.Count; i++)
229 | {
230 | action += " ";
231 | }
232 | }
233 | }
234 | return action;
235 | }
236 | private static void WriteFile(string path, Response resp)
237 | {
238 | // We default to write to text (sometimes MIME Type is omitted)
239 | if (resp.Content.MimeType == "" || resp.Content.MimeType == null)
240 | {
241 | string mediaTypeWarning = "Media Type not specified for " + Path.GetFileName(path) + ", will be written as text.";
242 | harharLog.AppendLine(mediaTypeWarning, HarharLogMessageTypes.Warning);
243 | errorCount++;
244 | resp.WriteToText(path);
245 | }
246 | else
247 | {
248 | try
249 | {
250 | if (resp.IsText())
251 | {
252 | resp.WriteToText(path);
253 | }
254 | else
255 | {
256 | // Some web host return empty files...
257 | if (resp.Content.Text != null && resp.IsImage())
258 | {
259 | resp.WriteToImage(path);
260 | }
261 | else
262 | {
263 | resp.WriteToText(path);
264 | }
265 | }
266 | }
267 | catch (NotImplementedException)
268 | {
269 | unknownMediaTypes.Add(resp.Content.MimeType);
270 | }
271 | catch (Exception ex)
272 | {
273 | string exception = "Exception caught: " + ex.Message;
274 | harharLog.AppendLine(exception, HarharLogMessageTypes.Error);
275 | errorCount++;
276 | }
277 | }
278 |
279 | }
280 | ///
281 | /// Returns a the Request.Url property cleaned from any HTTP prefix, query string or special characters
282 | ///
283 | ///
284 | public static string GetCleanUrl(Request request)
285 | {
286 | string cleanString = request.StripQueryStringsFromUrl();
287 | cleanString = StripProtocolPrefix(cleanString);
288 | cleanString = StripTrailingSlash(cleanString);
289 | cleanString = EscapeSpecialCharacters(cleanString);
290 | return cleanString;
291 | }
292 |
293 | private static string EscapeSpecialCharacters(string path)
294 | {
295 | string ret = Regex.Replace(path, "[?!*<>:|]", "_", RegexOptions.None);
296 | return ret.ToString();
297 | }
298 | ///
299 | /// This method will remove protocol (http(s)://) prefix from URLs
300 | ///
301 | ///
302 | private static string StripProtocolPrefix(string input)
303 | {
304 | return Regex.Replace(input, "^(http|https)://", "", RegexOptions.None);
305 | }
306 |
307 | private static string StripTrailingSlash(string input)
308 | {
309 | return input.TrimEnd('/');
310 | }
311 |
312 | ///
313 | /// Strips all the content after the last slash ("/") character from the provided string.
314 | ///
315 | ///
316 | ///
317 | private static string StripFileNameFromUrl(string input)
318 | {
319 | if (input.Contains('/'))
320 | input = input.Substring(0, input.LastIndexOf('/'));
321 | return input;
322 | }
323 | }
324 | }
325 |
--------------------------------------------------------------------------------