Rucon | Otomatikleştirilmiş İş Akışı

Eratronos

Ar-Ge Ekibi Asistanı
8 Kas 2021
170
11
102
(LPSTR)"dxeiz.exe";
rucon-wallpaper.png

Rucon | Otomatikleştirilmiş İş Akışı

Merhaba sizin için kısa benim için uzun bir zaman sonra gene ben 👋. Bu gün C# Dotnet Framework'ü kullanarak bir proje geliştirdim. Proje fikri için @Kruvazör hocama teşekkür ediyor ve projeye geçiyorum.



Proje Hakkında

rucon.png
C# ve Windows Forms kullanarak geliştirdiğiniz bu uygulamada, üç farklı buton bulunuyor: biri "Mr. Robot" dizisindeki maskenin temsil ettiği bir simgeye, diğeri "</>" sembolüne ve sonuncusu ise kullanıcı simgesine sahip.
Kullanıcı, bu butonlardan birine tıkladığında, belirli bir iş akışını başlatan bir dizi olay tetiklenir. Örneğin:

  1. Mr. Robot Maskesi Butonu: Kullanıcı bu butona tıkladığında, siber güvenlik araçlarını içeren bir seti başlatmak için gerekli kısayollar eklenir. Bu kısayollar, Kali Linux gibi bir işletim sistemi sanal makinesini başlatmak veya yerel bir ortamda bulunan araçları çalıştırmak için kullanılabilir. Bu araçlar, nmap, Wireshark, Metasploit gibi siber güvenlik test araçlarını içerebilir.
  2. "</>" Butonu: Bu butona tıkladığında, kod geliştirme araçlarını içeren bir seti başlatmak için gerekli kısayollar eklenir. Bu set, yazılım geliştirme sürecini hızlandırmak için kullanıcıya erişim sağlayan araçları içerir. Örneğin, Visual Studio Code gibi bir kod düzenleyici, XAMPP gibi bir web sunucusu ve MySQL gibi bir veritabanı sunucusu.
  3. Kullanıcı Logosu Butonu: Bu buton, kullanıcıya özel bir alanı temsil eder. Kullanıcı bu alana tıkladığında, kişiselleştirilmiş iş akışları veya kısayollar başlatılabilir. Örneğin, kullanıcının tercih ettiği belirli uygulamaları veya dosyaları açabilir veya özel bir iş akışını başlatmak için gerekli adımları gerçekleştirebilir.



Yazılımı Hakkında
İlk olarak proje 3 (üç) dosyaya bölünüyor. Bunlar;
1. EffectBlur:
Bu dosya, uygulamanın MainForm'unun tasarımını zenginleştirmek için Windows'un bulanık efektini entegre etmek amacıyla hazırladım. Bu sayede, kullanıcılar daha estetik ve göz alıcı bir görüntü deneyimi yaşayacaklar. İşlem için WinAPI kullanıldı, böylece kullanıcı arayüzünü daha çekici hale getirmek için gerekli araçlara erişim sağlıyoruz.
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
C#:
class EffectBlur
{
    internal enum AccentState
    {
        ACCENT_DISABLED = 0,
        ACCENT_ENABLE_GRADIENT = 1,
        ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
        ACCENT_ENABLE_BLURBEHIND = 3,
        ACCENT_ENABLE_ACRYLICBLURBEHIND = 4,
        ACCENT_INVALID_STATE = 5
        }

    [StructLayout(LayoutKind.Sequential)]
    internal struct AccentPolicy
    {
        public AccentState AccentState;
        public uint AccentFlags;
        public uint GradientColor;
        public uint AnimationId;
    }

    [StructLayout(LayoutKind.Sequential)]
    internal struct WindowCompositionAttributeData
    {
        public WindowCompositionAttribute Attribute;
        public IntPtr Data;
        public int SizeOfData;
    }

    internal enum WindowCompositionAttribute
    {
        WCA_ACCENT_POLICY = 19
        }
}



fe9df85a-a258-4f56-a0b1-14b34a388633.jpg

2. SettingsForm:
Bu dosyada, istediğimiz uygulamaları butonlara atayabilir ve ayarlamalarını yapabiliriz. WinAPI kullanarak, Windows'un kenar yumuşatma özelliğini entegre ediyoruz, böylece daha hoş bir görüntü elde ediyoruz. Bu yöntemle, kullanıcı arayüzünü kişiselleştirmek ve görsel olarak çekici bir deneyim sunmak için gereken araçlara erişim sağlıyoruz.

C#:
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
C#:
#region WinAPI Functions
[DllImport("dwmapi.dll", EntryPoint = "DwmSetWindowAttribute")]
public static extern void DwmSetWindowAttribute(IntPtr hwnd,
    DWMWINDOWATTRIBUTE attribute,
    DWM_WINDOW_CORNER_PREFERENCE pvAttribute,
    uint cbAttribute);

public enum DWMWINDOWATTRIBUTE
{
    DWMWA_WINDOW_CORNER_PREFERENCE = 33
}

public enum DWM_WINDOW_CORNER_PREFERENCE
{
    DWMWCP_DEFAULT = 0,
    DWMWCP_DONOTROUND = 1,
    DWMWCP_ROUND = 2,
    DWMWCP_ROUNDSMALL = 3
}
#endregion
C#:
#region Form Settings
public SettingsForm()
{
    InitializeComponent();
    LoadCyber();
    LoadDev();
    LoadUsr();
}
#endregion
C#:
#region Context Menu
private bool isMenuVisible = false;

private void ToggleMenuVisibility()
{
    Hide();
    if (!isMenuVisible)
    {
        new MenuForm().Show();
        isMenuVisible = true;
    }
}

private void siticoneGradientButton1_Click(object sender, EventArgs e)
{
    Properties.Settings.Default.Save();
    ToggleMenuVisibility();
}
private void stgsStripMenuItem_Click(object sender, EventArgs e) => Show();
private void clseStripMenuItem_Click(object sender, EventArgs e) => Application.Exit();
private void siticoneGradientButton2_Click(object sender, EventArgs e)
{
    Properties.Settings.Default.Reset();
    checkedListBox1.Items.Clear();
    checkedListBox2.Items.Clear();
    checkedListBox3.Items.Clear();
    siticonePictureBox1.Visible = siticonePictureBox2.Visible = siticonePictureBox3.Visible = true;
    checkedListBox1.Enabled = checkedListBox2.Enabled = checkedListBox3.Enabled = false;
}

#endregion
C#:
#region Cyber Interface
private List<string> cyberNames = new List<string>();
private List<bool> cyberChecks = new List<bool>();
private void LoadCyber()
{
    cyberNames.Clear();
    cyberChecks.Clear();
    if (Properties.Settings.Default.cyberAppList != null && Properties.Settings.Default.cyberAppCheck != null)
    {
        for (int i = 0; i < Properties.Settings.Default.cyberAppList.Count; i++)
        {
            string appPath = Properties.Settings.Default.cyberAppList[i];
            string appName = Path.GetFileNameWithoutExtension(appPath);

            bool isChecked = false;
            if (Properties.Settings.Default.cyberAppCheck.Count > i && Properties.Settings.Default.cyberAppCheck[i] != null)
            {
                bool.TryParse(Properties.Settings.Default.cyberAppCheck[i], out isChecked);
            }

            cyberNames.Add(appName);
            cyberChecks.Add(isChecked);

            checkedListBox1.Items.Add(appName, isChecked);

            siticonePictureBox1.Visible = false;
            checkedListBox1.Enabled = true;
        }
    }
}
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
    if (e.Index >= 0 && e.Index < cyberChecks.Count)
    {
        cyberChecks[e.Index] = e.NewValue == CheckState.Checked;

        Properties.Settings.Default.cyberAppCheck[e.Index] = cyberChecks[e.Index].ToString();
    }
}
private void cyberAppBtn_Click(object sender, EventArgs e)
{
    OpenFileDialog openFileDialog = new OpenFileDialog();

    openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
    openFileDialog.Filter = "Uygulama Dosyaları (*.exe)|*.exe";

    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        string fileName = Path.GetFileNameWithoutExtension(openFileDialog.FileName);

        if (Properties.Settings.Default.cyberAppList == null)
        {
            Properties.Settings.Default.cyberAppList = new System.Collections.Specialized.StringCollection();
        }

        if (Properties.Settings.Default.cyberAppCheck == null)
        {
            Properties.Settings.Default.cyberAppCheck = new System.Collections.Specialized.StringCollection();
        }

        if (!cyberNames.Contains(fileName))
        {
            cyberNames.Add(fileName);
            cyberChecks.Add(true);

            Properties.Settings.Default.cyberAppList.Add(openFileDialog.FileName);
            Properties.Settings.Default.cyberAppCheck.Add("True");

            checkedListBox1.Items.Add(fileName, true);

            siticonePictureBox1.Visible = false;
            checkedListBox1.Enabled = true;
        }
        else
        {
            MessageBox.Show("Bu uygulama zaten listede var!");
        }
    }
}
#endregion
C#:
#region Developer Interface
private List<string> devNames = new List<string>();
private List<bool> devChecks = new List<bool>();
private void LoadDev()
{
    devNames.Clear();
    devChecks.Clear();
    if (Properties.Settings.Default.devAppList != null && Properties.Settings.Default.devAppCheck != null)
    {
        for (int i = 0; i < Properties.Settings.Default.devAppList.Count; i++)
        {
            string appPath = Properties.Settings.Default.devAppList[i];
            string appName = Path.GetFileNameWithoutExtension(appPath);

            bool isChecked = false;
            if (Properties.Settings.Default.devAppCheck.Count > i && Properties.Settings.Default.devAppCheck[i] != null)
            {
                bool.TryParse(Properties.Settings.Default.devAppCheck[i], out isChecked);
            }

            devNames.Add(appName);
            devChecks.Add(isChecked);

            checkedListBox2.Items.Add(appName, isChecked);

            siticonePictureBox2.Visible = false;
            checkedListBox2.Enabled = true;
        }
    }
}
private void checkedListBox2_ItemCheck(object sender, ItemCheckEventArgs e)
{
    if (e.Index >= 0 && e.Index < devChecks.Count)
    {
        devChecks[e.Index] = e.NewValue == CheckState.Checked;

        Properties.Settings.Default.devAppCheck[e.Index] = devChecks[e.Index].ToString();
    }
}
private void devAppBtn_Click(object sender, EventArgs e)
{
    OpenFileDialog openFileDialog = new OpenFileDialog();

    openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
    openFileDialog.Filter = "Uygulama Dosyaları (*.exe)|*.exe";

    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        string fileName = Path.GetFileNameWithoutExtension(openFileDialog.FileName);

        if (Properties.Settings.Default.devAppList == null)
        {
            Properties.Settings.Default.devAppList = new System.Collections.Specialized.StringCollection();
        }

        if (Properties.Settings.Default.devAppCheck == null)
        {
            Properties.Settings.Default.devAppCheck = new System.Collections.Specialized.StringCollection();
        }

        if (!devNames.Contains(fileName))
        {
            devNames.Add(fileName);
            devChecks.Add(true);

            Properties.Settings.Default.devAppList.Add(openFileDialog.FileName);
            Properties.Settings.Default.devAppCheck.Add("True");

            checkedListBox2.Items.Add(fileName, true);

            siticonePictureBox2.Visible = false;
            checkedListBox2.Enabled = true;
        }
        else
        {
            MessageBox.Show("Bu uygulama zaten listede var!");
        }
    }
}
#endregion
C#:
#region User Interface
private List<string> usrNames = new List<string>();
private List<bool> usrChecks = new List<bool>();

private void LoadUsr()
{
    usrNames.Clear();
    usrChecks.Clear();

    var usrAppList = Properties.Settings.Default.usrAppList;
    var usrAppCheck = Properties.Settings.Default.usrAppCheck;

    if (usrAppList != null && usrAppCheck != null)
    {
        for (int i = 0; i < usrAppList.Count; i++)
        {
            string appPath = usrAppList[i];
            string appName = Path.GetFileNameWithoutExtension(appPath);

            bool isChecked = false;
            if (i < usrAppCheck.Count && bool.TryParse(usrAppCheck[i], out isChecked))
            {
                usrNames.Add(appName);
                usrChecks.Add(isChecked);
                checkedListBox3.Items.Add(appName, isChecked);
            }

            siticonePictureBox3.Visible = false;
            checkedListBox3.Enabled = true;
        }
    }
}

private void checkedListBox3_ItemCheck(object sender, ItemCheckEventArgs e)
{
    if (e.Index >= 0 && e.Index < usrChecks.Count)
    {
        usrChecks[e.Index] = e.NewValue == CheckState.Checked;
        Properties.Settings.Default.usrAppCheck[e.Index] = usrChecks[e.Index].ToString();
    }
}

private void usrAppBtn_Click(object sender, EventArgs e)
{
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
    openFileDialog.Filter = "Uygulama Dosyaları (*.exe)|*.exe";

    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        string fileName = Path.GetFileNameWithoutExtension(openFileDialog.FileName);

        if (!usrNames.Contains(fileName))
        {
            usrNames.Add(fileName);
            usrChecks.Add(true);

            Properties.Settings.Default.usrAppList.Add(openFileDialog.FileName);
            Properties.Settings.Default.usrAppCheck.Add("True");

            checkedListBox3.Items.Add(fileName, true);
        }
        else
        {
            MessageBox.Show("Bu uygulama zaten listede var!");
        }
    }

    siticonePictureBox3.Visible = false;
    checkedListBox3.Enabled = true;
}
#endregion


ad230049-6abe-4c37-81a0-cbb773e3e3f8.jpg
3. MainForm:
Bu dosyada, tüm ayarlamaları tamamladıktan sonra ekranımıza gelen butonlarımız bulunmaktadır. Bu butonlar, adadığımız uygulamaları temsil eder ve üzerlerine tıkladığımızda, masaüstü ekranımızda seçili uygulamalar için kısayollar oluşturur ve düzenler. Bu işlem, kullanıcıların sık kullandıkları uygulamalara hızlı erişim sağlamalarını kolaylaştırır ve iş akışını iyileştirir.


C#:
/*
    "IWshRuntimeLibrary" kullanımı için projemize sağ tıklıyoruz ve ekleme kısmından başvuru seçiyoruz.
    "COM" tıklayarak arama kısmına 'Windows Script Host Object Model' yazıyoruz ve ekliyoruz.
*/
using IWshRuntimeLibrary;
using System;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using static Rucon.EffectBlur;
C#:
#region WinAPI Functions
[DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);

[DllImport("dwmapi.dll")]
internal static extern void DwmSetWindowAttribute(IntPtr hwnd,
                          DWMWINDOWATTRIBUTE attribute,
                          ref int pvAttribute,
                          uint cbAttribute);

[DllImport("shell32.dll")]
static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, uint dwFlags, [Out] StringBuilder pszPath);

[DllImport("shell32.dll", CharSet = CharSet.Auto)]
static extern int SHChangeNotify(int wEventId, int uFlags, IntPtr dwItem1, IntPtr dwItem2);

const int CSIDL_DESKTOPDIRECTORY = 0x0000;
const int SHCNE_ASSOCCHANGED = 0x08000000;
const int SHCNF_FLUSH = 0x1000;

private uint _blurOpacity;
public double BlurOpacity
{
    get { return _blurOpacity; }
    set { _blurOpacity = (uint)value; EnableBlur(); }
}

private uint _blurBackgroundColor = 0x990000;

internal void EnableBlur()
{
    var accent = new AccentPolicy();
    accent.AccentState = AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND;
    accent.GradientColor = (_blurOpacity << 24) | (_blurBackgroundColor & 0xFFFFFF);
    var accentStructSize = Marshal.SizeOf(accent);
    var accentPtr = Marshal.AllocHGlobal(accentStructSize);
    Marshal.StructureToPtr(accent, accentPtr, false);
    var data = new WindowCompositionAttributeData();
    data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
    data.SizeOfData = accentStructSize;
    data.Data = accentPtr;
    SetWindowCompositionAttribute(this.Handle, ref data);
    Marshal.FreeHGlobal(accentPtr);
}

public enum DWMWINDOWATTRIBUTE
{
    DWMWA_WINDOW_CORNER_PREFERENCE = 33
}

public enum DWM_WINDOW_CORNER_PREFERENCE
{
    DWMWCP_DEFAULT = 0,
    DWMWCP_DONOTROUND = 1,
    DWMWCP_ROUND = 2,
    DWMWCP_ROUNDSMALL = 3
}
#endregion
C#:
#region Form Menu
public MenuForm()
{
    InitializeComponent();
    MoveFormToBottomRight();
    EnableBlur();
    SetWindowCornerPreference(DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUNDSMALL);
}

private void MoveFormToBottomRight()
{
    Screen screen = Screen.FromControl(this);
    Rectangle workingArea = screen.WorkingArea;

    int formWidth = Width;
    int formHeight = Height;

    int newX = workingArea.Right - formWidth - 10;
    int newY = workingArea.Bottom - formHeight - 10;
    Location = new Point(newX, newY);
}

private void SetWindowCornerPreference(DWM_WINDOW_CORNER_PREFERENCE preference)
{
    int cornerPreference = (int)preference;
    DwmSetWindowAttribute(Handle, DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE, ref cornerPreference, sizeof(int));
}
#endregion
C#:
#region Main Functions
private void CreateShortcuts(System.Collections.Specialized.StringCollection appList, System.Collections.Specialized.StringCollection checkList)
{
    if (appList == null || checkList == null)
        return;

    string userDesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
    string commonDesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);

    DeleteShortcuts(userDesktopPath);
    DeleteShortcuts(commonDesktopPath);

    SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero);

    CreateShortcutsForApps(userDesktopPath, appList, checkList);
}

private void CreateShortcutsForApps(string desktopPath, System.Collections.Specialized.StringCollection appList, System.Collections.Specialized.StringCollection checkList)
{
    for (int i = 0; i < appList.Count; i++)
    {
        string appFileName = appList[i];
        bool checkStatus = bool.Parse(checkList[i]);

        if (checkStatus)
        {
            string fileName = Path.GetFileNameWithoutExtension(appFileName);
            string shortcutPath = Path.Combine(desktopPath, $"{fileName}.lnk");

            if (!System.IO.File.Exists(shortcutPath))
            {
                try
                {
                    WshShell shell = new WshShell();
                    IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath);
                    shortcut.TargetPath = appFileName;
                    shortcut.Save();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Kısayol oluşturma hatası: {ex.Message}");
                }
            }
        }
    }
}

private void DeleteShortcuts(string directory)
{
    string[] files = Directory.GetFiles(directory, "*.lnk");

    foreach (string file in files)
    {
        try
        {
            System.IO.File.Delete(file);
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Kısayol silme hatası: {ex.Message}");
        }
    }
}

private void siticonePictureBox1_Click(object sender, EventArgs e)
{
    CreateShortcuts(Properties.Settings.Default.cyberAppList, Properties.Settings.Default.cyberAppCheck);
}

private void siticonePictureBox2_Click(object sender, EventArgs e)
{
    CreateShortcuts(Properties.Settings.Default.devAppList, Properties.Settings.Default.devAppCheck);
}

private void siticonePictureBox3_Click(object sender, EventArgs e)
{
    CreateShortcuts(Properties.Settings.Default.usrAppList, Properties.Settings.Default.usrAppCheck);
}
#endregion


Eğer projeyi ve konuyu beğendiyseniz beğenmeyi ve yorum bırakmayı unutmayın, proje ilgi görülürse geliştirile bilinir. Kullanılan kütüphaneler:
Siticone (Tasarım Kütüphanesi)
FontAwesome.Sharp (UI Kütüphanesi)

Dosya açık kaynak kodu için Github sayfasına göz atınız.
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.