/
Detection.cs
78 lines (67 loc) · 2.5 KB
/
Detection.cs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using OpenMetaverse;
using OpenMetaverse.Assets;
namespace FirstBot
{
static class Detection
{
private static TextureRequestState resultState;
private static AssetTexture asset = null;
private static AutoResetEvent DownloadHandle = new AutoResetEvent(false);
private static List<Primitive> foundPrims;
public static void FindObjects(GridClient Client)
{
Vector3 location = Client.Self.SimPosition;
foundPrims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(
delegate(Primitive prim)
{
Vector3 pos = prim.Position;
return (prim.ParentID == 0 && pos != Vector3.Zero);
}
);
}
public static void DetectSteg(GridClient Client)
{
int count = 1;
Console.WriteLine("Found: " + foundPrims.Count + " objects");
foreach (Primitive p in foundPrims)
{
Console.Write(count + ". Analyzing texture...");
UUID textureID = p.Textures.DefaultTexture.TextureID;
DownloadHandle.Reset();
Client.Assets.RequestImage(textureID, ImageType.Normal, ImageReceived);
if (DownloadHandle.WaitOne(1000, false))
{
if (resultState == TextureRequestState.Finished)
{
if (asset != null && asset.Decode())
{
string s = "";
var file = asset.AssetData;
for (int i = 0; i < file.Length; i++)
{
s += String.Format("{0:X2}", file[i]);
}
if (s.IndexOf("504B0304") != -1)
{
Extraction.DownloadSteg(asset.AssetData, asset.AssetID, Client);
}
else
Console.WriteLine("Nothing found.");
}
}
}
count++;
}
}
private static void ImageReceived(TextureRequestState state, AssetTexture assetID)
{
resultState = state;
asset = assetID;
DownloadHandle.Set();
}
}
}