├── .gitignore
├── LICENSE
├── README.md
└── ShellcodeBakery
├── ShellcodeBakery.sln
└── ShellcodeBakery
├── App.config
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── ShellcodeBakery.csproj
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 VollRagm
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ShellcodeBakery
2 | A simple tool to assemble shellcode ready to be copy-pasted into code
3 |
4 | ## Usage
5 | Enter the ASM code in the left Text box. Make sure to use [FASM Syntax](https://flatassembler.net/docs.php?article=manual).
6 | Select the output settings and hit assemble.
7 | Example output when checking all 3 boxes:
8 | Input:
9 | ```asm
10 | mov rcx, 69420h
11 | sub rsp, 20h
12 | call rax
13 | add rsp, 20h
14 | cmp rax, 2
15 | jne 0x5
16 | ```
17 |
18 | Output:
19 | ```cpp
20 | char shellcode[] = {
21 | 0x48, 0xC7, 0xC1, 0x20, 0x94, 0x06, 0x00, // 0x0: mov rcx, 69420h
22 | 0x48, 0x83, 0xEC, 0x20, // 0x7: sub rsp, 20h
23 | 0xFF, 0xD0, // 0xB: call rax
24 | 0x48, 0x83, 0xC4, 0x20, // 0xD: add rsp, 20h
25 | 0x48, 0x83, 0xF8, 0x02, // 0x11: cmp rax, 2
26 | 0x75, 0x03 // 0x15: jne 0x5
27 | };
28 | ```
29 |
30 | 
31 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32126.315
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShellcodeBakery", "ShellcodeBakery\ShellcodeBakery.csproj", "{732AECA1-5089-4CB6-8A4E-F56B7F66BFBF}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {732AECA1-5089-4CB6-8A4E-F56B7F66BFBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {732AECA1-5089-4CB6-8A4E-F56B7F66BFBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {732AECA1-5089-4CB6-8A4E-F56B7F66BFBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {732AECA1-5089-4CB6-8A4E-F56B7F66BFBF}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {7CAF17E4-D102-41F4-986A-2C2F5B639F60}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ShellcodeBakery
3 | {
4 | partial class MainForm
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Windows Form Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.InputTextBox = new System.Windows.Forms.RichTextBox();
33 | this.OutputTextBox = new System.Windows.Forms.RichTextBox();
34 | this.Assemble32Btn = new System.Windows.Forms.Button();
35 | this.BeautifyCb = new System.Windows.Forms.CheckBox();
36 | this.AnnotateInstructionsCb = new System.Windows.Forms.CheckBox();
37 | this.AnnotateOffsetsCb = new System.Windows.Forms.CheckBox();
38 | this.Assemble64Btn = new System.Windows.Forms.Button();
39 | this.LanguageSelection = new System.Windows.Forms.ComboBox();
40 | this.label1 = new System.Windows.Forms.Label();
41 | this.linkLabel1 = new System.Windows.Forms.LinkLabel();
42 | this.SuspendLayout();
43 | //
44 | // InputTextBox
45 | //
46 | this.InputTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
47 | this.InputTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
48 | this.InputTextBox.Font = new System.Drawing.Font("Consolas", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
49 | this.InputTextBox.ForeColor = System.Drawing.Color.White;
50 | this.InputTextBox.Location = new System.Drawing.Point(12, 28);
51 | this.InputTextBox.Name = "InputTextBox";
52 | this.InputTextBox.Size = new System.Drawing.Size(350, 445);
53 | this.InputTextBox.TabIndex = 0;
54 | this.InputTextBox.Text = "";
55 | this.InputTextBox.WordWrap = false;
56 | //
57 | // OutputTextBox
58 | //
59 | this.OutputTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
60 | this.OutputTextBox.Font = new System.Drawing.Font("Consolas", 11.25F);
61 | this.OutputTextBox.ForeColor = System.Drawing.Color.White;
62 | this.OutputTextBox.Location = new System.Drawing.Point(461, 35);
63 | this.OutputTextBox.Name = "OutputTextBox";
64 | this.OutputTextBox.Size = new System.Drawing.Size(529, 441);
65 | this.OutputTextBox.TabIndex = 0;
66 | this.OutputTextBox.Text = "";
67 | this.OutputTextBox.WordWrap = false;
68 | //
69 | // Assemble32Btn
70 | //
71 | this.Assemble32Btn.Location = new System.Drawing.Point(368, 224);
72 | this.Assemble32Btn.Name = "Assemble32Btn";
73 | this.Assemble32Btn.Size = new System.Drawing.Size(88, 23);
74 | this.Assemble32Btn.TabIndex = 1;
75 | this.Assemble32Btn.Text = "Assemble x32";
76 | this.Assemble32Btn.UseVisualStyleBackColor = true;
77 | this.Assemble32Btn.Click += new System.EventHandler(this.Assemble32Btn_Click);
78 | //
79 | // BeautifyCb
80 | //
81 | this.BeautifyCb.AutoSize = true;
82 | this.BeautifyCb.ForeColor = System.Drawing.Color.White;
83 | this.BeautifyCb.Location = new System.Drawing.Point(602, 12);
84 | this.BeautifyCb.Name = "BeautifyCb";
85 | this.BeautifyCb.Size = new System.Drawing.Size(64, 17);
86 | this.BeautifyCb.TabIndex = 2;
87 | this.BeautifyCb.Text = "Beautify";
88 | this.BeautifyCb.UseVisualStyleBackColor = true;
89 | //
90 | // AnnotateInstructionsCb
91 | //
92 | this.AnnotateInstructionsCb.AutoSize = true;
93 | this.AnnotateInstructionsCb.ForeColor = System.Drawing.Color.White;
94 | this.AnnotateInstructionsCb.Location = new System.Drawing.Point(682, 12);
95 | this.AnnotateInstructionsCb.Name = "AnnotateInstructionsCb";
96 | this.AnnotateInstructionsCb.Size = new System.Drawing.Size(126, 17);
97 | this.AnnotateInstructionsCb.TabIndex = 2;
98 | this.AnnotateInstructionsCb.Text = "Annotate Instructions";
99 | this.AnnotateInstructionsCb.UseVisualStyleBackColor = true;
100 | //
101 | // AnnotateOffsetsCb
102 | //
103 | this.AnnotateOffsetsCb.AutoSize = true;
104 | this.AnnotateOffsetsCb.ForeColor = System.Drawing.Color.White;
105 | this.AnnotateOffsetsCb.Location = new System.Drawing.Point(807, 12);
106 | this.AnnotateOffsetsCb.Name = "AnnotateOffsetsCb";
107 | this.AnnotateOffsetsCb.Size = new System.Drawing.Size(105, 17);
108 | this.AnnotateOffsetsCb.TabIndex = 2;
109 | this.AnnotateOffsetsCb.Text = "Annotate Offsets";
110 | this.AnnotateOffsetsCb.UseVisualStyleBackColor = true;
111 | //
112 | // Assemble64Btn
113 | //
114 | this.Assemble64Btn.Location = new System.Drawing.Point(368, 253);
115 | this.Assemble64Btn.Name = "Assemble64Btn";
116 | this.Assemble64Btn.Size = new System.Drawing.Size(88, 23);
117 | this.Assemble64Btn.TabIndex = 1;
118 | this.Assemble64Btn.Text = "Assemble x64";
119 | this.Assemble64Btn.UseVisualStyleBackColor = true;
120 | this.Assemble64Btn.Click += new System.EventHandler(this.Assemble64Btn_Click);
121 | //
122 | // LanguageSelection
123 | //
124 | this.LanguageSelection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
125 | this.LanguageSelection.FormattingEnabled = true;
126 | this.LanguageSelection.Items.AddRange(new object[] {
127 | "C/C++",
128 | "C#"});
129 | this.LanguageSelection.Location = new System.Drawing.Point(461, 10);
130 | this.LanguageSelection.Name = "LanguageSelection";
131 | this.LanguageSelection.Size = new System.Drawing.Size(121, 21);
132 | this.LanguageSelection.TabIndex = 3;
133 | //
134 | // label1
135 | //
136 | this.label1.AutoSize = true;
137 | this.label1.ForeColor = System.Drawing.Color.White;
138 | this.label1.Location = new System.Drawing.Point(12, 12);
139 | this.label1.Name = "label1";
140 | this.label1.Size = new System.Drawing.Size(33, 13);
141 | this.label1.TabIndex = 4;
142 | this.label1.Text = "ASM:";
143 | //
144 | // linkLabel1
145 | //
146 | this.linkLabel1.AutoSize = true;
147 | this.linkLabel1.LinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(12)))), ((int)(((byte)(113)))), ((int)(((byte)(180)))));
148 | this.linkLabel1.Location = new System.Drawing.Point(291, 10);
149 | this.linkLabel1.Name = "linkLabel1";
150 | this.linkLabel1.Size = new System.Drawing.Size(71, 13);
151 | this.linkLabel1.TabIndex = 5;
152 | this.linkLabel1.TabStop = true;
153 | this.linkLabel1.Text = "FASM Syntax";
154 | //
155 | // MainForm
156 | //
157 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
158 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
159 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
160 | this.ClientSize = new System.Drawing.Size(1002, 496);
161 | this.Controls.Add(this.linkLabel1);
162 | this.Controls.Add(this.label1);
163 | this.Controls.Add(this.LanguageSelection);
164 | this.Controls.Add(this.AnnotateOffsetsCb);
165 | this.Controls.Add(this.AnnotateInstructionsCb);
166 | this.Controls.Add(this.BeautifyCb);
167 | this.Controls.Add(this.Assemble64Btn);
168 | this.Controls.Add(this.Assemble32Btn);
169 | this.Controls.Add(this.OutputTextBox);
170 | this.Controls.Add(this.InputTextBox);
171 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
172 | this.Name = "MainForm";
173 | this.Text = "ShellcodeBakery";
174 | this.ResumeLayout(false);
175 | this.PerformLayout();
176 |
177 | }
178 |
179 | #endregion
180 |
181 | private System.Windows.Forms.RichTextBox InputTextBox;
182 | private System.Windows.Forms.RichTextBox OutputTextBox;
183 | private System.Windows.Forms.Button Assemble32Btn;
184 | private System.Windows.Forms.CheckBox BeautifyCb;
185 | private System.Windows.Forms.CheckBox AnnotateInstructionsCb;
186 | private System.Windows.Forms.CheckBox AnnotateOffsetsCb;
187 | private System.Windows.Forms.Button Assemble64Btn;
188 | private System.Windows.Forms.ComboBox LanguageSelection;
189 | private System.Windows.Forms.Label label1;
190 | private System.Windows.Forms.LinkLabel linkLabel1;
191 | }
192 | }
193 |
194 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using Binarysharp.Assemblers.Fasm;
4 | using System.Linq;
5 |
6 | namespace ShellcodeBakery
7 | {
8 | public partial class MainForm : Form
9 | {
10 | public MainForm()
11 | {
12 | InitializeComponent();
13 | LanguageSelection.SelectedIndex = 0;
14 | }
15 |
16 | private void AssembleInternal(string bitness)
17 | {
18 | OutputTextBox.Clear();
19 |
20 | int lineCount = 0;
21 | int currentOffset = 0;
22 |
23 | string output = LanguageSelection.SelectedIndex == 0 ? CSyntax : CSharpSyntax;
24 | if (BeautifyCb.Checked) output += "\n";
25 |
26 | foreach(var line in InputTextBox.Lines)
27 | {
28 | try
29 | {
30 | if (string.IsNullOrWhiteSpace(line))
31 | {
32 | ++lineCount;
33 | continue;
34 | }
35 |
36 | var instruction = AssembleSingleInstruction(line, bitness, lineCount == InputTextBox.Lines.Length - 1, out int length);
37 | output += (BeautifyCb.Checked ? "\t": "") + instruction;
38 |
39 | if (BeautifyCb.Checked)
40 | {
41 | if (AnnotateOffsetsCb.Checked)
42 | {
43 | output += GenerateTabs(length) + $" // 0x{currentOffset:X}";
44 | }
45 |
46 | if (AnnotateInstructionsCb.Checked)
47 | {
48 | output += $"{(AnnotateOffsetsCb.Checked ? ": " : GenerateTabs(length) + " // ")}" + line;
49 | }
50 | output += "\n";
51 | }
52 |
53 | currentOffset += length;
54 | ++lineCount;
55 | }
56 | catch (FasmAssemblerException ex)
57 | {
58 | MessageBox.Show($"Error: {ex.ErrorCode}\nLine: {lineCount}");
59 | string[] lines = InputTextBox.Lines;
60 |
61 | if (lines[lineCount].Contains(" ; <-- Error:"))
62 | lines[lineCount] = lines[lineCount].Remove(lines[lineCount].IndexOf(" ; <-- Error:"));
63 |
64 | lines[lineCount] = lines[lineCount] + " ; <-- Error: " + ex.ErrorCode;
65 | InputTextBox.Lines = lines;
66 | return;
67 | }
68 | }
69 |
70 | output += BeautifyCb.Checked ? "};" : " };";
71 |
72 | OutputTextBox.Text = output;
73 | }
74 |
75 | private string GenerateTabs(int instructionLength)
76 | {
77 | int[] lengths = { 8, 6, 5, 4, 3, 2, 1, 1 };
78 | string output = "";
79 | for (int i = 0; i < lengths[instructionLength - 1]; i++)
80 | output += "\t";
81 |
82 | return output;
83 | }
84 |
85 | private string AssembleSingleInstruction(string instruction, string bitness, bool final, out int length)
86 | {
87 | string[] mnemonics = { bitness, instruction };
88 | var asm = FasmNet.Assemble(mnemonics);
89 | string output = "";
90 |
91 | foreach(var b in asm)
92 | {
93 | output += "0x" + b.ToString("X2") + ", ";
94 | }
95 | if (final) output = output.Remove(output.Length - 2);
96 | length = asm.Length;
97 | return output;
98 | }
99 |
100 | private void Assemble32Btn_Click(object sender, EventArgs e)
101 | {
102 | AssembleInternal("use32");
103 | }
104 |
105 | private void Assemble64Btn_Click(object sender, EventArgs e)
106 | {
107 | AssembleInternal("use64");
108 | }
109 |
110 | string CSharpSyntax = "byte[] shellcode = { ";
111 | string CSyntax = "char shellcode[] = { ";
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace ShellcodeBakery
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new MainForm());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ShellcodeBakery")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ShellcodeBakery")]
13 | [assembly: AssemblyCopyright("Copyright © 2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("732aeca1-5089-4cb6-8a4e-f56b7f66bfbf")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace ShellcodeBakery.Properties
13 | {
14 | ///
15 | /// A strongly-typed resource class, for looking up localized strings, etc.
16 | ///
17 | // This class was auto-generated by the StronglyTypedResourceBuilder
18 | // class via a tool like ResGen or Visual Studio.
19 | // To add or remove a member, edit your .ResX file then rerun ResGen
20 | // with the /str option, or rebuild your VS project.
21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24 | internal class Resources
25 | {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources()
33 | {
34 | }
35 |
36 | ///
37 | /// Returns the cached ResourceManager instance used by this class.
38 | ///
39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
40 | internal static global::System.Resources.ResourceManager ResourceManager
41 | {
42 | get
43 | {
44 | if ((resourceMan == null))
45 | {
46 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShellcodeBakery.Properties.Resources", typeof(Resources).Assembly);
47 | resourceMan = temp;
48 | }
49 | return resourceMan;
50 | }
51 | }
52 |
53 | ///
54 | /// Overrides the current thread's CurrentUICulture property for all
55 | /// resource lookups using this strongly typed resource class.
56 | ///
57 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
58 | internal static global::System.Globalization.CultureInfo Culture
59 | {
60 | get
61 | {
62 | return resourceCulture;
63 | }
64 | set
65 | {
66 | resourceCulture = value;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace ShellcodeBakery.Properties
13 | {
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
17 | {
18 |
19 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
20 |
21 | public static Settings Default
22 | {
23 | get
24 | {
25 | return defaultInstance;
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/ShellcodeBakery.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {732AECA1-5089-4CB6-8A4E-F56B7F66BFBF}
8 | WinExe
9 | ShellcodeBakery
10 | ShellcodeBakery
11 | v4.8
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | x86
28 | none
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 | false
35 |
36 |
37 |
38 | ..\packages\Fasm.NET.1.70.03.2\lib\Fasm.NET.dll
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | Form
55 |
56 |
57 | MainForm.cs
58 |
59 |
60 |
61 |
62 | MainForm.cs
63 |
64 |
65 | ResXFileCodeGenerator
66 | Resources.Designer.cs
67 | Designer
68 |
69 |
70 | True
71 | Resources.resx
72 |
73 |
74 |
75 | SettingsSingleFileGenerator
76 | Settings.Designer.cs
77 |
78 |
79 | True
80 | Settings.settings
81 | True
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/ShellcodeBakery/ShellcodeBakery/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------