Skip to content

Commit 50c68b0

Browse files
committed
first commit
0 parents  commit 50c68b0

File tree

10 files changed

+1471
-0
lines changed

10 files changed

+1471
-0
lines changed

README.md

Whitespace-only changes.

RunAs.dpr

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
(*******************************************************************************
2+
3+
Jean-Pierre LESUEUR (@DarkCoderSc)
4+
https://www.phrozen.io/
5+
6+
7+
License : MIT
8+
9+
*******************************************************************************)
10+
11+
program RunAs;
12+
13+
{$APPTYPE CONSOLE}
14+
15+
{$R *.res}
16+
17+
uses
18+
Windows,
19+
System.SysUtils,
20+
UntFunctions in 'Units\UntFunctions.pas';
21+
22+
{-------------------------------------------------------------------------------
23+
Usage Banner
24+
-------------------------------------------------------------------------------}
25+
function DisplayHelpBanner() : String;
26+
begin
27+
result := '';
28+
///
29+
30+
WriteLn;
31+
WriteColoredWord('RunAs');
32+
Write('.');
33+
WriteColoredWord('exe');
34+
WriteLn(' -u <username> -p <password> -e <executable> [-d <domain>] [-a <arguments>] [-h]');
35+
WriteLn;
36+
WriteLn('-h : Start process hidden.');
37+
WriteLn;
38+
end;
39+
40+
41+
var SET_USERNAME : String = '';
42+
SET_PASSWORD : String = '';
43+
SET_DOMAINNAME : String = '';
44+
SET_PROGRAM : String = '';
45+
SET_ARGUMENTS : String = '';
46+
SET_HIDDEN : Boolean = False;
47+
48+
LRet : Integer;
49+
50+
begin
51+
try
52+
{
53+
Parse Arguments
54+
}
55+
if NOT GetCommandLineOption('u', SET_USERNAME) then
56+
raise Exception.Create('');
57+
58+
if NOT GetCommandLineOption('p', SET_PASSWORD) then
59+
raise Exception.Create('');
60+
61+
if NOT GetCommandLineOption('e', SET_PROGRAM) then
62+
raise Exception.Create('');
63+
64+
GetCommandLineOption('d', SET_DOMAINNAME);
65+
GetCommandLineOption('a', SET_ARGUMENTS);
66+
67+
SET_HIDDEN := CommandLineOptionExists('h');
68+
69+
{
70+
Run Program
71+
}
72+
LRet := CreateProcessAsUser(
73+
SET_PROGRAM,
74+
SET_ARGUMENTS,
75+
SET_USERNAME,
76+
SET_PASSWORD,
77+
SET_DOMAINNAME,
78+
(NOT SET_HIDDEN)
79+
);
80+
81+
case LRet of
82+
{
83+
Access Denied
84+
}
85+
5 : begin
86+
Debug('Generally this error is related to file access permission. You should place the file you are trying to execute into a folder accessible by any user. (Ex: C:\ProgramData\)', dlWarning);
87+
end;
88+
end;
89+
except
90+
on E: Exception do begin
91+
if (E.Message <> '') then
92+
Debug(Format('%s : %s', [E.ClassName, E.Message]), dlError)
93+
else
94+
DisplayHelpBanner();
95+
end;
96+
end;
97+
end.

RunAs.dproj

+1,039
Large diffs are not rendered by default.

RunAs.dproj.local

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<BorlandProject>
3+
<Transactions>
4+
<Transaction>2020/03/03 11:06:06.000.717,=C:\Users\PhrozenLab\Documents\Embarcadero\Studio\Projects\Unit1.pas</Transaction>
5+
<Transaction>2020/04/30 15:03:58.000.912,=C:\Users\PhrozenLab\Documents\Embarcadero\Studio\Projects\Unit1.pas</Transaction>
6+
<Transaction>2020/05/18 17:25:24.921,C:\Users\PhrozenLab\Desktop\Open Source Projects\Git\run-as\RunAs.dproj=C:\Users\PhrozenLab\Documents\Embarcadero\Studio\Projects\Project2.dproj</Transaction>
7+
<Transaction>2020/05/18 17:29:47.499,=C:\Users\PhrozenLab\Desktop\Open Source Projects\Git\run-as\Unit1.pas</Transaction>
8+
<Transaction>2020/05/18 17:29:59.546,C:\Users\PhrozenLab\Desktop\Open Source Projects\Git\run-as\Units\UntFunctions.pas=C:\Users\PhrozenLab\Desktop\Open Source Projects\Git\run-as\Unit1.pas</Transaction>
9+
</Transactions>
10+
</BorlandProject>

RunAs.res

96 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)