Skip to content

Commit

Permalink
Hexviewer, highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Aug 16, 2024
1 parent 1c4eac9 commit 932e379
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
39 changes: 27 additions & 12 deletions Protest/Front/hexviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,11 @@ class HexViewer extends Window {
this.lastIndentationElement = element;

element.onclick = ()=> {
const listElements = this.list.childNodes;
const hexElements = hexContainer.childNodes;
const charElements = charContainer.childNodes;
const listElements = this.list.childNodes;

for (let i = 0; i < this.hexBox.childNodes.length; i++) {
for (let i=0; i<this.hexBox.childNodes.length; i++) {
if (this.hexBox.childNodes[i].className === "hexviewer-separator") continue;
for (let j = 0; j < this.hexBox.childNodes[i].childNodes.length; j++) {
this.hexBox.childNodes[i].childNodes[j].style.color = "";
Expand All @@ -454,17 +454,17 @@ class HexViewer extends Window {
}
}

for (let i = 0; i < hexElements.length; i++) {
for (let i=0; i<hexElements.length; i++) {
hexElements[i].style.color = charElements[i].style.color = "";
hexElements[i].style.backgroundColor = charElements[i].style.backgroundColor = "";
}

for (let i = 0; i < listElements.length; i++) {
for (let i=0; i<listElements.length; i++) {
listElements[i].style.color = "";
listElements[i].style.backgroundColor = "";
}

for (let i = offset; i < Math.min(offset + length, hexElements.length); i++) {
for (let i=offset; i<Math.min(offset + length, hexElements.length); i++) {
hexElements[i].style.color = charElements[i].style.color = "#000";
hexElements[i].style.backgroundColor = charElements[i].style.backgroundColor = "var(--clr-select)";

Expand All @@ -473,13 +473,28 @@ class HexViewer extends Window {
}

if (isDnsPointers) {
if (length === 2) {
const byteA = parseInt("0x"+hexElements[offset].textContent, 16);
const byteB = parseInt("0x"+hexElements[offset+1].textContent, 16);
if ((byteA & 0xC0) === 0xC0) {
let pointer = ((byteA & 0x3F) << 8) | byteB;
hexElements[pointer].style.color = "#000";
hexElements[pointer].style.backgroundColor = "var(--clr-warning)";
if (true) {
let byteA = parseInt("0x"+hexElements[offset].textContent, 16);
let byteB = parseInt("0x"+hexElements[offset+1].textContent, 16);
let pIndex = ((byteA & 0x3F) << 8) | byteB;

while (pIndex < hexElements.length - 1) {
byteA = parseInt("0x"+hexElements[pIndex].textContent, 16);
if (byteA === 0) { break; }

if ((byteA & 0xC0) === 0xC0) {
byteB = parseInt("0x"+hexElements[pIndex+1].textContent, 16);
pIndex = ((byteA & 0x3F) << 8) | byteB;
continue;
}

hexElements[pIndex].style.color = "#000";
hexElements[pIndex].style.backgroundColor = "var(--clr-warning)";

charElements[pIndex].style.color = "#000";
charElements[pIndex].style.backgroundColor = "var(--clr-warning)";

pIndex++;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Protest/Front/reverseproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ class ReverseProxy extends List {
}

EditDialog(entry=null, isRunning=false) {
const dialog = this.DialogBox("460px");
const dialog = this.DialogBox("480px");
if (dialog === null) return;

const {okButton, innerBox} = dialog;
Expand Down
16 changes: 8 additions & 8 deletions Protest/Misc/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ internal static bool Load() {
front_path = value.ToString();
break;

case "backdoor":
backdoor = String.Equals(value.ToString(), "true", StringComparison.OrdinalIgnoreCase);
break;

case "http_prefix":
httpPrefixes.Add(value.ToString());
break;

case "backdoor":
backdoor = String.Equals(value.ToString(), "true", StringComparison.OrdinalIgnoreCase);
break;

case "ip2location_api_key":
IP2LOCATION_API_KEY = value.ToString();
break;
Expand Down Expand Up @@ -124,16 +124,16 @@ internal static void CreateDefault() {
builder.AppendLine($"#front_path = {front_path}");
builder.AppendLine();
#endif

builder.AppendLine($"# When the backdoor is enabled, requests originating from the loopback address bypass authentication.");
builder.AppendLine($"backdoor = {backdoor.ToString().ToLower()}");
builder.AppendLine();

builder.AppendLine("http_prefix = http://127.0.0.1:8080/");
builder.AppendLine("http_prefix = http://[::1]:8080/");
builder.AppendLine("#http_prefix = https://+:443/");
builder.AppendLine();

builder.AppendLine($"# When the backdoor is enabled, requests originating from the loopback address bypass authentication.");
builder.AppendLine($"backdoor = {backdoor.ToString().ToLower()}");
builder.AppendLine();

builder.AppendLine("#ip2location_api_key = PASTE-API-KEY-HERE");
builder.AppendLine();

Expand Down
2 changes: 1 addition & 1 deletion Protest/Protocols/Mdns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ private static string ExtractName(byte[] response, int startIndex) {
while (index < response.Length && response[index] != 0) {
if ((response[index] & 0xC0) == 0xC0) { //pointer
int pointer = ((response[index] & 0x3F) << 8) | response[index + 1];
var pointerName = ExtractName(response, pointer);
string pointerName = ExtractName(response, pointer);
pointerName.AsSpan().CopyTo(name.Slice(nameIndex));
nameIndex += pointerName.Length;
break;
Expand Down

0 comments on commit 932e379

Please sign in to comment.