Skip to content

Commit 03eab7d

Browse files
committed
updates
1 parent 1925d9c commit 03eab7d

File tree

14 files changed

+89
-30
lines changed

14 files changed

+89
-30
lines changed

Diff for: ch11_reading_offline_hives/NodeKey.cs

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ private void ReadNodeStructure(BinaryReader hive) {
6565

6666
buf = hive.ReadBytes(this.NameLength);
6767
this.Name = System.Text.Encoding.UTF8.GetString(buf);
68+
69+
hive.BaseStream.Position = this.ClassnameOffset + 4 + 4096;
70+
this.ClassnameData = hive.ReadBytes (this.ClassnameLength);
6871
}
6972

7073
private void ReadChildrenNodes(BinaryReader hive) {

Diff for: ch11_reading_offline_hives/Program.cs

+66-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,78 @@
11
using System;
2+
using System.Linq;
23
using ntregsharp;
4+
using System.Collections.Generic;
5+
using System.Text;
36

47
namespace ch11_reading_offline_hives
58
{
69
class MainClass
710
{
811
public static void Main (string[] args)
912
{
10-
RegistryHive hive = new RegistryHive (args [0]);
11-
12-
Console.WriteLine("The rootkey's name is " + hive.RootKey.Name);
13+
RegistryHive systemHive = new RegistryHive (args [0]);
14+
byte[] bootKey = GetBootKey (systemHive);
15+
16+
Console.WriteLine ("Boot key: " + BitConverter.ToString (bootKey));
17+
}
18+
19+
static byte[] GetBootKey(RegistryHive hive){
20+
ValueKey controlSet = GetValueKey (hive, "Select|Default");
21+
int cs = BitConverter.ToInt32 (controlSet.Data, 0);
22+
23+
StringBuilder scrambledKey = new StringBuilder ();
24+
foreach (string key in new string[] {"JD", "Skew1", "GBG", "Data"}) {
25+
NodeKey nk = GetNodeKey (hive, "ControlSet00" + cs + "|Control|Lsa|" + key);
26+
27+
for (int i = 0; i < nk.ClassnameLength && i < 8; i++)
28+
scrambledKey.Append ((char)nk.ClassnameData [i*2]);
29+
}
30+
31+
byte[] skey = StringToByteArray (scrambledKey.ToString ());
32+
byte[] descramble = new byte[] { 0x8, 0x5, 0x4, 0x2, 0xb, 0x9, 0xd, 0x3,
33+
0x0, 0x6, 0x1, 0xc, 0xe, 0xa, 0xf, 0x7 };
34+
35+
byte[] bootkey = new byte[16];
36+
for (int i = 0; i < bootkey.Length; i++)
37+
bootkey[i] = skey [descramble [i]];
38+
39+
return bootkey;
40+
}
41+
42+
static byte[] StringToByteArray(string hex) {
43+
return Enumerable.Range(0, hex.Length)
44+
.Where(x => x % 2 == 0)
45+
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
46+
.ToArray();
47+
}
48+
49+
static NodeKey GetNodeKey(RegistryHive hive, string path){
50+
51+
NodeKey node = null;
52+
string[] paths = path.Split ('|');
53+
54+
for (int i = 0;i < paths.Length; i++) {
55+
56+
if (node == null)
57+
node = hive.RootKey;
58+
59+
foreach (NodeKey child in node.ChildNodes) {
60+
if (child.Name == paths [i]) {
61+
node = child;
62+
break;
63+
}
64+
}
65+
}
66+
67+
return node;
68+
}
69+
70+
static ValueKey GetValueKey(RegistryHive hive, string path) {
71+
72+
string keyname = path.Split ('|').Last ();
73+
NodeKey node = GetNodeKey (hive, path);
74+
75+
return node.ChildValues.SingleOrDefault (v => v.Name == keyname);
1376
}
1477
}
1578
}

Diff for: ch11_reading_offline_hives/ch11_reading_offline_hives.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<ErrorReport>prompt</ErrorReport>
1818
<WarningLevel>4</WarningLevel>
1919
<PlatformTarget>x86</PlatformTarget>
20-
<Commandlineparameters>/Users/bperry/system.hive</Commandlineparameters>
20+
<Commandlineparameters>/Users/bperry/Documents/system.hive</Commandlineparameters>
2121
<ConsolePause>false</ConsolePause>
2222
</PropertyGroup>
2323
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">

Diff for: ch13_automating_metasploit/ch13_automating_metasploit.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<ItemGroup>
3434
<Reference Include="System" />
3535
<Reference Include="MsgPack">
36-
<HintPath>..\packages\MsgPack.Cli.0.6.5\lib\net45\MsgPack.dll</HintPath>
36+
<HintPath>..\packages\MsgPack.Cli.0.6.8\lib\net45\MsgPack.dll</HintPath>
3737
</Reference>
3838
</ItemGroup>
3939
<ItemGroup>

Diff for: ch14_automating_arachni/ch14_automating_arachni_http.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<ItemGroup>
3333
<Reference Include="System" />
3434
<Reference Include="Newtonsoft.Json">
35-
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
35+
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
3636
</Reference>
3737
</ItemGroup>
3838
<ItemGroup>

Diff for: ch14_automating_arachni_rpc/ch14_automating_arachni_rpc.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<HintPath>..\packages\zlib.net.1.0.4.0\lib\zlib.net.dll</HintPath>
3636
</Reference>
3737
<Reference Include="MsgPack">
38-
<HintPath>..\packages\MsgPack.Cli.0.6.7\lib\net45\MsgPack.dll</HintPath>
38+
<HintPath>..\packages\MsgPack.Cli.0.6.8\lib\net45\MsgPack.dll</HintPath>
3939
</Reference>
4040
</ItemGroup>
4141
<ItemGroup>

Diff for: ch2_vulnerable_json_endpoint/ch2_vulnerable_json_endpoint.csproj

+4-7
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@
3333
<Reference Include="System.Web" />
3434
<Reference Include="System.Xml" />
3535
<Reference Include="System.Web.Services" />
36-
<Reference Include="Mono.Security">
37-
<HintPath>..\packages\Npgsql.2.2.5\lib\net45\Mono.Security.dll</HintPath>
38-
</Reference>
39-
<Reference Include="Npgsql">
40-
<HintPath>..\packages\Npgsql.2.2.5\lib\net45\Npgsql.dll</HintPath>
41-
</Reference>
4236
<Reference Include="System.Data" />
4337
<Reference Include="Newtonsoft.Json">
44-
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
38+
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
39+
</Reference>
40+
<Reference Include="Npgsql">
41+
<HintPath>..\packages\Npgsql.3.0.5\lib\net45\Npgsql.dll</HintPath>
4542
</Reference>
4643
</ItemGroup>
4744
<ItemGroup>

Diff for: ch3_vulnerable_soap_endpoint/ch3_vulnerable_soap_endpoint.csproj

+2-5
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@
3333
<Reference Include="System.Web" />
3434
<Reference Include="System.Xml" />
3535
<Reference Include="System.Web.Services" />
36-
<Reference Include="Mono.Security">
37-
<HintPath>..\packages\Npgsql.2.2.5\lib\net45\Mono.Security.dll</HintPath>
38-
</Reference>
36+
<Reference Include="System.Data" />
3937
<Reference Include="Npgsql">
40-
<HintPath>..\packages\Npgsql.2.2.5\lib\net45\Npgsql.dll</HintPath>
38+
<HintPath>..\packages\Npgsql.3.0.5\lib\net45\Npgsql.dll</HintPath>
4139
</Reference>
42-
<Reference Include="System.Data" />
4340
</ItemGroup>
4441
<ItemGroup>
4542
<Content Include="Global.asax" />

Diff for: ch5_automating_nessus/ch5_automating_nessus.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<Reference Include="System" />
3333
<Reference Include="System.Xml" />
3434
<Reference Include="Newtonsoft.Json">
35-
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
35+
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
3636
</Reference>
3737
</ItemGroup>
3838
<ItemGroup>

Diff for: ch7_automating_openvas/OpenVASManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public OpenVASManager (OpenVASSession session)
1212
if (session != null)
1313
_session = session;
1414
else
15-
throw new Exception ("Session cannot be null");
15+
throw new ArgumentNullException ("session");
1616
}
1717

1818
public XDocument GetVersion ()

Diff for: ch7_automating_openvas/OpenVASSession.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ private bool ValidateServerCertificate (object sender, X509Certificate certifica
113113
public void Dispose ()
114114
{
115115
if (_stream != null) {
116-
_stream.Flush ();
117-
_stream = null;
116+
_stream.Dispose ();
118117
}
119118
}
120119
}

Diff for: ch8_automating_cuckoo/ch8_automating_cuckoo.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<ItemGroup>
3232
<Reference Include="System" />
3333
<Reference Include="Newtonsoft.Json">
34-
<HintPath>..\packages\Newtonsoft.Json.6.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
34+
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
3535
</Reference>
3636
</ItemGroup>
3737
<ItemGroup>

Diff for: ch9_automating_sqlmap/ch9_automating_sqlmap.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<ItemGroup>
3434
<Reference Include="System" />
3535
<Reference Include="Newtonsoft.Json">
36-
<HintPath>..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll</HintPath>
36+
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
3737
</Reference>
3838
</ItemGroup>
3939
<ItemGroup>

Diff for: ch9_automating_sqlmap_soap/ch9_automating_sqlmap_soap.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
</PropertyGroup>
3333
<ItemGroup>
3434
<Reference Include="System" />
35-
<Reference Include="Newtonsoft.Json">
36-
<HintPath>..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll</HintPath>
37-
</Reference>
3835
<Reference Include="System.Xml" />
3936
<Reference Include="System.Xml.Linq" />
37+
<Reference Include="Newtonsoft.Json">
38+
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
39+
</Reference>
4040
</ItemGroup>
4141
<ItemGroup>
4242
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -59,9 +59,9 @@
5959
</ItemGroup>
6060
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
6161
<ItemGroup>
62-
<None Include="packages.config" />
62+
<Folder Include="sqlmapsharp\" />
6363
</ItemGroup>
6464
<ItemGroup>
65-
<Folder Include="sqlmapsharp\" />
65+
<None Include="packages.config" />
6666
</ItemGroup>
6767
</Project>

0 commit comments

Comments
 (0)