-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathHTTPExploitExe.cs
146 lines (139 loc) · 6.06 KB
/
HTTPExploitExe.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Hacknet
{
internal class HTTPExploitExe : ExeModule
{
public static float DURATION = 14f;
public static float AFTER_COMPLETION_STALL = 1f;
public static float GRAPH_MOVEMENT = 22f;
private List<Vector2> backGraphPoints;
private float fastTimeAccum;
private List<Vector2> graphPoints;
private bool hasCompleted;
private float heightRange;
private float progress;
private float sucsessTimer = AFTER_COMPLETION_STALL;
private float tAccum;
public HTTPExploitExe(Rectangle location, OS operatingSystem)
: base(location, operatingSystem)
{
needsProxyAccess = true;
ramCost = 208;
IdentifierName = "Apache Web Server Worm";
}
public override void LoadContent()
{
base.LoadContent();
graphPoints = new List<Vector2>();
backGraphPoints = new List<Vector2>();
var num1 = 6f;
heightRange = (bounds.Height - 4 - 17)/3*2f;
var num2 = (int) ((bounds.Width - 4)/(double) num1);
var vector2 = new Vector2(2f, bounds.Height - 4 - 17);
graphPoints.Add(new Vector2(vector2.X, vector2.Y));
backGraphPoints.Add(new Vector2(vector2.X, vector2.Y));
for (var index = 1; index < num2 - 1; ++index)
{
graphPoints.Add(new Vector2(vector2.X,
vector2.Y - (float) (Utils.random.NextDouble()*0.2 + 0.3)*heightRange));
backGraphPoints.Add(new Vector2(vector2.X, vector2.Y - (float) Utils.random.NextDouble()*heightRange));
vector2.X += num1;
}
graphPoints.Add(new Vector2(vector2.X, vector2.Y));
backGraphPoints.Add(new Vector2(vector2.X, vector2.Y));
var computer = Programs.getComputer(os, targetIP);
if (computer == null)
return;
computer.hostileActionTaken();
}
public override void Update(float t)
{
base.Update(t);
tAccum += t*1.5f;
fastTimeAccum += t*4f;
progress += t/DURATION;
if (progress >= 1.0)
{
progress = 1f;
if (!hasCompleted)
{
Completed();
hasCompleted = true;
}
sucsessTimer -= t;
if (sucsessTimer > 0.0)
return;
isExiting = true;
}
else
{
for (var index = 1; index < graphPoints.Count - 1; ++index)
{
var vector2 = graphPoints[index];
var num1 = Math.Abs(vector2.Y - heightRange/2f)/(heightRange/2f);
var num2 = num1*num1;
var num3 = 30f - num2;
var num4 = num2*(float) ((1.0 - progress)*num3 + progress*30.0);
vector2.Y += (float) Math.Sin(fastTimeAccum + (double) (index*bounds.Width))*GRAPH_MOVEMENT*num4*t;
vector2.Y = Math.Min(vector2.Y, bounds.Height);
vector2.Y = Math.Max(vector2.Y, 0.0f);
graphPoints[index] = vector2;
vector2 = backGraphPoints[index];
var num5 = heightRange/2f - Math.Abs(vector2.Y - heightRange/2f);
vector2.Y += (float) Math.Sin(tAccum + (double) (index*bounds.Width))*GRAPH_MOVEMENT*num5*t;
backGraphPoints[index] = vector2;
}
}
}
public override void Draw(float t)
{
base.Draw(t);
drawOutline();
drawTarget("app:");
var destinationRectangle = bounds;
var vector2_1 = new Vector2(bounds.X, bounds.Y);
for (var index = 0; index < graphPoints.Count - 1; ++index)
{
var vector2_2 = backGraphPoints[index];
var vector2_3 = backGraphPoints[index + 1];
vector2_2.Y = Math.Min(vector2_2.Y, bounds.Height);
vector2_2.Y = Math.Max(vector2_2.Y, 0.0f);
vector2_3.Y = Math.Min(vector2_3.Y, heightRange);
vector2_3.Y = Math.Max(vector2_3.Y, 0.0f);
drawLine(vector2_2 + vector2_1, vector2_3 + vector2_1, os.subtleTextColor);
}
for (var index = 0; index < graphPoints.Count - 1; ++index)
drawLine(graphPoints[index] + vector2_1, graphPoints[index + 1] + vector2_1, Color.White);
destinationRectangle.X += 2;
destinationRectangle.Width -= 4;
destinationRectangle.Y = bounds.Y + bounds.Height - 1 - 13;
destinationRectangle.Height = 13;
spriteBatch.Draw(Utils.white, destinationRectangle, os.outlineColor*fade);
++destinationRectangle.X;
++destinationRectangle.Y;
destinationRectangle.Width -= 2;
destinationRectangle.Height -= 2;
spriteBatch.Draw(Utils.white, destinationRectangle, Color.White*fade);
destinationRectangle.Width = (int) (destinationRectangle.Width*(double) progress);
spriteBatch.Draw(Utils.white, destinationRectangle, os.highlightColor*fade);
}
public void drawLine(Vector2 origin, Vector2 dest, Color c)
{
var y = Vector2.Distance(origin, dest);
var rotation = (float) Math.Atan2(dest.Y - (double) origin.Y, dest.X - (double) origin.X) + 4.712389f;
spriteBatch.Draw(Utils.white, origin, new Rectangle?(), c*fade, rotation, Vector2.Zero, new Vector2(1f, y),
SpriteEffects.None, 0.5f);
}
public override void Completed()
{
base.Completed();
var computer = Programs.getComputer(os, targetIP);
if (computer == null)
return;
computer.openPort(80, os.thisComputer.ip);
}
}
}