clonevault's People
Forkers
gavz lunarobliq askyeye timb-machine-mirrors rvrsh3ll leftp reverse-ex gkfnf preventions gh0st0ne pafh99clonevault's Issues
Multiple memory leaks in RestoreCredential
Multiple memory leaks in RestoreCredential()
public static void RestoreCredential(string jsonString, bool fromFile = false)
{
Console.WriteLine("[*] Importing credential");
if (fromFile)
{
jsonString = System.IO.File.ReadAllText(jsonString);
}
ExportCred export = JsonConvert.DeserializeObject<ExportCred>(jsonString);
CREDENTIAL new_cred = new CREDENTIAL();
new_cred.Flags = export.Flags;
new_cred.Type = export.Type;
new_cred.TargetName = Marshal.StringToCoTaskMemUni(export.TargetName);
new_cred.Comment = Marshal.StringToCoTaskMemUni(export.Comment);
! memory for new_cred.Comment was never freed
new_cred.LastWritten = export.LastWritten;
new_cred.CredentialBlobSize = export.CredentialBlobSize;
int size = export.CredentialBlob.Length;
IntPtr unmanagedPointer = Marshal.AllocHGlobal(size);
! No corresponding call to Marshal.FreeHGlobal (unmanagedPointer)
Marshal.Copy(export.CredentialBlob, 0, unmanagedPointer, export.CredentialBlob.Length);
new_cred.CredentialBlob = unmanagedPointer;
new_cred.Persist = export.Persist;
new_cred.AttributeCount = export.AttributeCount;
...
for (int n = 0; n < export.AttributeCount; n++)
{
ExportAttrib attrib = export.Attributes[n];
Console.WriteLine("[-] Attribute {0}", attrib.Keyword);
NativeCredentialAttribute nativeAttrib = new NativeCredentialAttribute();
nativeAttrib.Keyword = attrib.Keyword;
nativeAttrib.Flags = attrib.Flags;
nativeAttrib.ValueSize = attrib.ValueSize;
IntPtr ptrattribvalue = Marshal.AllocHGlobal((int)attrib.ValueSize);
! No corresponding call to Marshal.FreeHGlobal (ptrattribvalue)
Marshal.Copy(attrib.Value, 0, ptrattribvalue, (int)attrib.ValueSize);
nativeAttrib.Value = ptrattribvalue;
var attrbuff = Marshal.AllocHGlobal(asize);
! No corresponding call to Marshal.FreeHGlobal (attrbuff)
Marshal.StructureToPtr(nativeAttrib, attrbuff, false);
Marshal.Copy(attrbuff, oadata, n * asize, asize);
}
...
GCHandle pinned = default(GCHandle);
pinned = GCHandle.Alloc(oadata, GCHandleType.Pinned);
! This pinned variable had no corresponding call to .Free()
new_cred.Attributes = pinned.AddrOfPinnedObject();
new_cred.TargetAlias = Marshal.StringToCoTaskMemUni(export.TargetAlias);
new_cred.UserName = Marshal.StringToCoTaskMemUni(export.UserName);
bool written = CredWrite(ref new_cred, 0);
+ Marshal.FreeCoTaskMem(new_cred.Attributes);
+ Marshal.FreeCoTaskMem(new_cred.TargetAlias);
+ Marshal.FreeCoTaskMem(new_cred.TargetName);
+ Marshal.FreeCoTaskMem(new_cred.UserName);
+ Marshal.FreeCoTaskMem(new_cred.Comment);
+ Marshal.FreeHGlobal(unmanagedPointer);
+ pinned.Free();
if (!written)
{
int lastError = Marshal.GetLastWin32Error();
throw new Exception(string.Format("CredWrite failed with the error code {0}.", lastError));
! This exception code path did not release native resources
}
Console.WriteLine("[*] Finished importing credential");
- Marshal.FreeCoTaskMem(new_cred.Attributes);
- Marshal.FreeCoTaskMem(new_cred.TargetAlias);
- Marshal.FreeCoTaskMem(new_cred.TargetName);
- Marshal.FreeCoTaskMem(new_cred.UserName);
}
CloneVault/CloneVault/Program.cs
Line 160 in 875bb40
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.