c-sharp
-
RSA: Encrypt in .NET & Decrypt in Python
So… one of my current projects required the following actions: asymmetrically encrypt a string in .NET using a public key and decrypt it in a python script using a private key. The problem that I’ve encountered was that, apparently, I...
-
C# Predict the Random Number Generator of .NET
This post targets to underline the predictability of the random… or better said pseudo-random number generator (PRNG) exposed by the .NET framework (aka the Random() class), under certain assumptions. Because of the nature of the implementation, 100% accuracy can be...
-
C# Naive Bayes Basic OCR (w/ Example)
Hello again; I’m back - once again sacrificing my time for homework so I can publish something that I find more interesting. So if anyone is still reading this: the whole article is about OCR (which stands for Optical Character...
-
C# Prevent Decompilation by Decrypting Source at Runtime
Hello world! Today we continue the “Trolling the Decompiler” series (first part here: Prevent Reflector from Decompiling) but now with a more serious approach - this one should work on any decompiler. The point is: it is rather difficult to...
-
C# Send Data Between Processes (w/ Memory Mapped File)
If you’re reading this right now you’re probably developing some application that has 2 or more processes and you want those processes to share some data with each other. There are multiple ways to pass data between processes (IPC), each...
-
C# Minecraft Pixel Art Generator
Good morning class, (see what I did there:P ?) Today we will discuss a very important subject: creating pixel art in Minecraft from a given image. Ok guys, so I saw people creating pixel art in Minecraft (trying...
-
C# Inject a Dll into a Process (w/ CreateRemoteThread)
Since I’ve been asked if this is possible - well…you can do DLL Injection using C# but the injected DLL must be written in a language that doesn’t depend on a CLR (C/C++ would be a good option here, but...
-
Call a C# Method from C/C++ (native process)
This article presents a method of loading a managed (C#) dll in a native (C++) process by using the Common Language Runtime (CLR). Basically, it refers to calling a C# method from C/C++ and enables calling managed code from native...
-
C# Get Frames from a GIF
This is a simple method to extract a certain frame (or all of them) from a GIF, using C#. As always, .NET provides all the functions we need, so it shouldn’t take more than 12 lines of code. Basic Information...
-
C# How to Scan a Process' Memory
This article is about how to get the memory dump of a process, by checking almost all memory addresses that can store data. Since C# is quite a high level programming language, I think this is the only method available...
-
C# Password Protected File
In this article…I’ll talk about how to protect a file with a password (any file type) - without using ZIP or any other archivers. The file will be encrypted and then ‘attached’ to an executable, which will be later used...
-
C# Create Secure Desktop (Anti-Keylogger)
Since the number of Keyloggers keeps growing, I decided to publish this little trick hoping that it might be useful for someone. I discovered it when I was looking on how User Account Control/UAC from Windows 7 protects the data...
-
C# Make a Critical Process (BSoD if Killed)
A critical process is a type of process that Windows requires to be running - csrss.exe is an example of such process. Whenever a process like this finishes its execution (or it’s terminated) Windows will respond with an authentic Blue...
-
C# Detect if Debugger is Attached
This method is used to detect if a running process has a debugger attached to it. It involves using CheckRemoteDebuggerPresent, imported from kernel32.dll via PInvoke. It’s a neat way to add a little bit of protection to your program, but...
-
C# Simple Syntax Highlighting
Some time ago, I had to make a project that required syntax highlighting - luckily I wasn’t the one who had to make that part. However the version used in the project was more complicated - so I decided to...
-
C# Read/Write another Process' Memory
Today’s tutorial is about…processes’ memory! In this article I’ll show you how to read/write a process’ memory using C#. This is a good way to learn a part of WinAPI and also understand the basics of memory allocation. I’ll be...
-
C#/PHP Compatible Encryption (AES256)
Finding a way to encrypt messages in C# and decrypting them in PHP or vice versa seems to be a “challenge” for many users. I wrote this tutorial to provide some help with this: below, you can find how to...
-
C# Backpropagation Tutorial (XOR)
I’ve been trying for some time to learn and actually understand how Backpropagation (aka backward propagation of errors) works and how it trains the neural networks. Since I encountered many problems while creating the program, I decided to write this...
-
C# Prevent Reflector from Decompiling
This is a simple way to protect your application from any so-called “cracker”, without involving obfuscation. Remember that this works only against Reflector (tested on: v7.5.2.1), any other decompilers are “immune”. Technical stuff… The main idea is this: you change...
-
C# Get Desktop Screenshot
I found this feature while looking inside Graphics class and since it was so simple to use, I decided to post it here. It basically allows you to take print screens programmatically and save them as local images or forward...
-
C# Protect the Password inside a TextBox
First of all, the TextBox Control is not a secure way to hold passwords - so don’t use it as it is by default. Even with a PasswordChar, the real password is still visible if you use a tool like...
-
C# Ascii Art Tutorial
If you got here, you probably want to know how Ascii Art works and how to use C# to transform images into text. We’ll do this by making good use of LockBits() and UnlockBits(), and also, a pointer - going...
-
C# Safe Encryption/Decryption using DPAPI
Data Protection API aka DPAPI is a neat service provided by Windows Operating Systems (newer than Windows 2000) that safely encrypts and decrypts user credentials, using the Triple-DES algorithm. You have to supply the data as byte array in order...
-
C# Register a Url Protocol
This tutorial will show you how to register a custom Url Protocol for your application. Basically, you can control your application by simply clicking an Url address like this one: myApp:doSomething In this tutorial, I’ll name the custom protocol myApp...
-
C# Synchronize 2 RichTextBoxes' Scroll
I recently had a problem when I tried to synchronize the scrolling between 2 RichTextBoxes - that was because these controls behave different than normal TextBoxes. However I managed to solve this…after some time, and I decided to post the...
-
C# Form Fade In/Fade Out
This short tutorial is made to show you how to create a fade in / fade out effect for a form. Since basic Windows Forms doesn’t provide such an option, it must be done manually. Note: we’ll use timers instead...
-
C# Create Child Forms
Child Forms are those forms that are found inside another form (parent form). There are multiple ways to create child forms - most of them require to use a MDI Container. Child Forms without MDI Container I, personally, had lots...
-
C# Disable RichTextBox's Smooth Scrolling
In this article I’ll show you how to disable RichTextBox’s Smooth Scrolling - aka make RichTextBox scroll line by line. I know this is a problem for many developers, it was a problem for me too, so that’s why I...
-
C# Falling Snowflakes on Desktop
Since it’s winter, I decided to write about how to create an application that makes snowflakes fall on your desktop. It’s just like snowing on your desktop, but the application is pretty basic so there’s space for improvements - I...
-
C# Send Text to Notepad
This tutorial focuses on sending text from a C# program to any other window by using 2 functions provided by user32.dll. The big advantage of this method is that the window you’re sending the text to doesn’t require focus. Don’t...
-
C# Edit Registry Keys or Values
First Before starting to edit registry values/keys, include in your project’s source this namespace Microsoft.Win32. It will give you access to the required Registry functions. So, make sure you add this: 1 using Microsoft.Win32; In order to edit anything, you...
-
C# WebClient with Cookies
Well, you’re probably reading this because you noticed that .NET’s WebClient doesn’t support cookies. Basically, the cookies which are received through the WebRequest are NOT stored and also NOT sent - this is how it works by default. How to...
-
C# Connecting to FTP Server
In this tutorial I will show you how to use C# to connect to a FTP server and perform basic operations: uploading a file downloading a file deleting a file 1.Connecting & Logging In Before doing operations on files, you...
-
C# Sending data using GET or POST
In this short article, I’ll show you how to send data to a website from a C# application using GET or POST method. The tutorial also includes how to receive data from a website, by getting the page’s source -...
-
C# Perceptron Tutorial
The Perceptron is basically the simplest learning algorithm, that uses only one neuron. An usual representation of a perceptron (neuron) that has 2 inputs looks like this: A 2 Inputs + Bias Perceptron Now for a better understanding: Input 1...
-
C# Simple Http Server
In this short tutorial I’ll explain how to make a simple Http Server using only C#. The server will be able to serve any page that contains client-side code (html and javascript). Basic stuff When a client requests a page...
-
C# Asynchronous Tcp Server
This is the model of an Asynchronous TCP server, that can have multiple clients connected, each one on it’s own thread - all of this is done using a relatively short and easy-to-remember code. If you don’t have basic knowledge...
-
C# Http Server With ASP.NET
This tutorial will show you how to create a HTTP server that can parse ASP.NET files. It will be able to serve pages containing html,css and server-side code. As always I’ll try to keep the code simple - luckily .NET...
-
C# Compile at Runtime
To our luck, .NET Framework contains some classes that allow us to access the compiler and with it, we can compile our code at runtime. Basically when our executable will run, it will compile a small piece of code stored...
-
C# EventHandler with Arguments
All the methods that are called by events require two arguments: object sender EventArgs e The event calls a method using those 2 parameters, so we can’t directly add a custom argument. If we have this code and we want...
-
C# Load dll at Runtime
This is a method used to import a dll during the program’s execution (at the runtime) without adding the actual library as a reference. Obviously, you will need: A DLL made in C# - only a function and a class...
-
C# Send email using Gmail
In this tutorial … we’ll send emails :) using C# of course. 1. Required: SMTP server I use: smtp.google.com , you must have a Gmail account Little attention / some basic knowledge of C# 2. Creating the client We start...
-
C# Countdown Timer
A timer in C # is an object that executes an action after a specified time interval - for example, it can call a method every 5 seconds. The best way to understand how it works is to use it...
-
C# Moving form without border/title bar
1. Removing the title bar and border In this tutorial I will show you how you can make a draggable window (Form) with no title bar or border. By default, when you remove the border of a Form, you can’t...
-
XNA Disable Profile check
HiDef is one of the 2 profiles available for developing games in XNA. But…this profile requires a direct3d/D3D compatible video card. It apparently checks for DirectX10 compatibility. XNA will check this before compiling/running the project and will throw an error...
-
C# Form with Gradient Background
Gradient is a method which consists in slowly switching from one color to another - it’s used very often in application’s design. In this tutorial I’ll show you how to create this effect using only code: First, create a Forms...
-
C# Connect to MySql
MsSql or MySql ? What to use ? I prefer MySql because I work with it more often. Unfortunately .NET doesn’t support by default this kind of database… There’s a solution! It’s a small library called Connector/NET, available on MySql’s...
-
C# Working with Xml Documents
XML is the main file type used to save our program’s data. In this tutorial, I’ll show you how to work with XML files in C#. I’ll be working with the following file: 1 2 3 4 5 6 7...
-
C# Simple Tcp Server
If you got here, you probably want to know how to make a simple server in C#, using the shortest possible code and the easiest method to understand. For the sake of simplicity we’ll make a synchronous server using a...