Hack Forums
[C] Changing Window Title To Random String - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] Changing Window Title To Random String (/showthread.php?tid=5196084)



Changing Window Title To Random String - Meterpreter - Mar 7, 2016

How would I go about changing a Win32 Window Title to a random string? I have a basic idea just wondering how it would be structured and written.

Here is my random string generation:

Code
void gen_random(char *s, const int len) {
    static const char alphanum[] =
        "0123456789"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "abcdefghijklmnopqrstuvwxyz";

    for (int i = 0; i < len; ++i) {
        s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
    }

    s[len] = 0;
}



* - __readgsqword - Mar 7, 2016

SetWindowTextW(FindWindowW(0,L"MyCurrentWindowTitle"),L"New Title");


* - Block4о - Mar 9, 2016

In C# you can do:

Code
public static string GetUniqueKey(int maxSize)
        {
            char[] chars = new char[62];
            chars =
            "abcdefghijklmnopqrstuvwxyzåäöABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ1234567890АаБбВвГгДдЕеӘәЖжЗзИиЙйКкЛлМмНнОоÖöПпПпрСсТтуФфХхҺһҺһЧч'ШшьЭэԚԜԝ".ToCharArray();
            byte[] data = new byte[1];
            RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
            crypto.GetNonZeroBytes(data);
            data = new byte[maxSize];
            crypto.GetNonZeroBytes(data);
            StringBuilder result = new StringBuilder(maxSize);
            foreach (byte b in data)
            {
                result.Append(chars[b % (chars.Length)]);
            }
            return result.ToString();
        }

Then to change the current form's name you can do:
Code
this.Text = GetUniqueKey(15);

Of course you need:
using System.Security.Cryptography;

Hope I helped


* - Aker15 - Mar 9, 2016

Why the fuck would you post some stupid fucking C# program? Like really fuck me, do you see c# section? No you see the motherfucking C/C++ section now get ur dumb ass out of here fuck me. Im in a bad mood and you just pushed my fucking buttons.


* - RISC - Mar 9, 2016

(Mar 9, 2016 05:46 AM)kraskobe Wrote:  In C# you can do:

Code
public static string GetUniqueKey(int maxSize)
        {
            char[] chars = new char[62];
            chars =
            "abcdefghijklmnopqrstuvwxyzåäöABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ1234567890АаБбВвГгДдЕеӘәЖжЗзИиЙйКкЛлМмНнОоÖöПпПпрСсТтуФфХхҺһҺһЧч'ШшьЭэԚԜԝ".ToCharArray();
            byte[] data = new byte[1];
            RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
            crypto.GetNonZeroBytes(data);
            data = new byte[maxSize];
            crypto.GetNonZeroBytes(data);
            StringBuilder result = new StringBuilder(maxSize);
            foreach (byte b in data)
            {
                result.Append(chars[b % (chars.Length)]);
            }
            return result.ToString();
        }

Then to change the current form's name you can do:
Code
this.Text = GetUniqueKey(15);

Of course you need:
using System.Security.Cryptography;

Hope I helped

Are you fucking retarded mate?


* - goshmulticoloredalto - Mar 12, 2016

(Mar 9, 2016 06:07 AM)Aker15 Wrote:  Why the fuck would you post some stupid fucking C# program? Like really fuck me, do you see c# section? No you see the motherfucking C/C++ section now get ur dumb ass out of here fuck me. Im in a bad mood and you just pushed my fucking buttons.

[Image: Salt_Shaker.jpg]


* - Mouse❤️ - Mar 12, 2016

(Mar 9, 2016 06:07 AM)Aker15 Wrote:  Why the fuck would you post some stupid fucking C# program? Like really fuck me, do you see c# section? No you see the motherfucking C/C++ section now get ur dumb ass out of here fuck me. Im in a bad mood and you just pushed my fucking buttons.
Not blaming you at all. Sick of seeing C# stuff in this board.

OP: Take the banned guy's advice.

SetWindowText is what you're looking for.