Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
Kerberos TGT Update
Browse files Browse the repository at this point in the history
  • Loading branch information
byt3n33dl3 committed Sep 8, 2024
1 parent 252a3f2 commit e34644d
Show file tree
Hide file tree
Showing 148 changed files with 20,614 additions and 0 deletions.
47 changes: 47 additions & 0 deletions inc/kerbtgs/CrackMapCore/Asn1/Asn1Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;

namespace Rubeus.Asn1 {
public static class Asn1Extensions {

public static byte[] DepadLeft(this byte[] data) {

int leadingZeros = 0;
for (var i = 0; i < data.Length; i++) {
if (data[i] == 0) {
leadingZeros++;
} else {
break;
}
}

byte[] result = new byte[data.Length - leadingZeros];
Array.Copy(data, leadingZeros, result, 0, data.Length - leadingZeros);
return result;
}

public static byte[] PadLeft(this byte[] data, int totalSize) {

if(data.Length == totalSize) {
return data;
}

if(totalSize < data.Length) {
throw new ArgumentException("data bigger than totalSize, cannot pad with 0's");
}

byte[] result = new byte[totalSize];
data.CopyTo(result, totalSize - data.Length);
return result;
}

public static byte[] PadRight(this byte[] data, int length) {
if (data.Length == length) {
return data;
}

var copy = new byte[length];
data.CopyTo(copy, length - data.Length);
return copy;
}
}
}
Loading

0 comments on commit e34644d

Please sign in to comment.