Sign in to follow this  
Followers 0
crashdemons

Quine Example

23 posts in this topic

#1 ·  Posted (edited)

A Quine is a program that can output it's own source without having direct access or user intervention.

(This Means no reading of the script file, prompting for source input, packaging the source, or using inbuilt source references)

A Quine is not necessarily malicious or self-duplicating, but rather an attempt at a theory.

Definition of Quine

Why torture ourselves making this this way? The reason is to [re]prove a concept of computing: that it is possible for a turing-complete language to output it's own source-code. (or optionally, output a program in another language that outputs the original source code; aka. a multiquine )

Here, are some AutoIt3 Quines:

My Quines:

One-line quines from my reply on Page 2:

ConsoleWrite(StringReplace("ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))
MsgBox(0,'',StringReplace("MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))

Old 2-Line Quine:

$x="$x=%srnMsgBox(0,'Quine Example',StringFormat($x,Chr(34)&$x&Chr(34)))"
MsgBox(0,'Quine Example',StringFormat($x,Chr(34)&$x&Chr(34)))

Skeleton/Customizable Quine (Page 2)

Global $gsQuine
eq("MsgBox(0,'program','first exec line')")
eq("MsgBox(0,'program','second exec line')")
Func eq($s)
Execute($s)
$gsQuine&=BinaryToString(0x22287165)&$s&BinaryToString(0x0A0D2922)
EndFunc
$x="Global $gsQuinern%sFunc eq($s)rnExecute($s)rn$gsQuine&=BinaryToString(0x22287165)&$s&BinaryToString(0x0A0D2922)rnEndFuncrn$x=%srnMsgBox(0,'Quine Example',StringFormat($x,$gsQuine,Chr(34)&$x&Chr(34)))"
MsgBox(0,'Quine Example',StringFormat($x,$gsQuine,Chr(34)&$x&Chr(34)))

Any Questions? :)

Quines by Michel Claveau:

$x="MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)"
MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)

$g=chr(34)
$x="MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)"
MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)

Images of past quines:

Posted Image

Posted Image

- - -

And for my next magic trick :) - an AutoIt3 / PHP Polyglot (non-quine and all too simple)

A Polyglot is a script that can perform the same actions in multiple languages without manipulation of the code.

;=- <?php
;/*
ConsoleWrite(";=- Hello World -=;");
;*/
; echo "Hello World";
; ?> -=;

In either language, this outputs ";=- Hello World -=;" to the console.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Sorry for bumping, but I just had to.

Just read the wikpedia page on Quine and thought to myself: Hey! Wonder if it have been done in autoit? And indeed it had!

Very nice work (and in only 2 lines):)

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Cool!

Share this post


Link to post
Share on other sites

Is this correct?

Posted Image

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Is this correct?

Posted Image

Ugh huh you bet its correct *Grinz*

if in doubt read Quine Definition

Edited by Gargy

01000001 01110101 01110100 01101111 01001001 01110100 00100000
An immortal object must be copied, so that we get a mortal copy of it, since we try not to destroy immortal objects.

Share this post


Link to post
Share on other sites

I thought the point was to output the whole source. There it only goes up to "MsgBox(0, 'Quine"

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I thought the point was to output the whole source. There it only goes up to "MsgBox(0, 'Quine"

You might have a vaild point there lets wait for Crash

lulz

*edit to conform

Edited by Gargy

01000001 01110101 01110100 01101111 01001001 01110100 00100000
An immortal object must be copied, so that we get a mortal copy of it, since we try not to destroy immortal objects.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

First:

Stop centering the text in the posts, are newspapers and books center justified? No.

Second:

Just include the entire source code using FileInstall()

- or -

Using a preprocessor directive:

#AutoIt3Wrapper_res_SaveSource

See other options:

http://www.autoitscript.com/forum/index.ph...install++source

Edited by weaponx

Share this post


Link to post
Share on other sites

You might have a vaild point there lets wait for Crash

lulz

your signature is soo big it makes the page have a sidewards scroollbar.

Share this post


Link to post
Share on other sites

That depends on how big screen you have :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Wow! don't think I've ever gotten this many replies.

Um yeah I think the $ before MsgBox was a typo when I was removing lines from it - I'll go fix it now.

Also, I'd be pleased if someone can make a different example

- although StringFormat is certainly easier than anything else I could think of.

wrapping the string in a function to try one-line makes it complicated, ugh because you have to repeat it 2+ etc.... *shrugs*

Let me know...

Shorter version of the "PHP/AutoIt" Polyglot (Editbox is broken on the first post)

;=- <?php /*
ConsoleWrite(";=- Hello World -=;");*/ echo "Hello World"; ?> -=;

PS:

I don't know exactly why it was only partially outputting for some - but just in case, try the newest edit that removed the extra '$' before MsgBox

-- also I noticed the icon on the dialog box where the problem is, I suppose it's possible there might be a compatibility issue with WINE? I don't know.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Hi!

This release, without the StringFormat:

$x="MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)"
MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)

Variante:

$g=chr(34)
$x="MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)"
MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)

_

Edited by Michel Claveau

Share this post


Link to post
Share on other sites

Cool! that works good :)


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

I am failing to see how this would be useful, you have to replicate every line of commands for running and outputting to the user. If you used something like this below you only have to define the code once:

$var = 'MsgBox(0,"","TEST")'

;Escape double quotes
$var = StringReplace($var, '"', '""')

;Format run command
$runCMD = StringFormat('"%s" /AutoIt3ExecuteLine "%s"', @AutoItExe, $var)

RunWait($runCMD)

Share this post


Link to post
Share on other sites

Wait you want run autoit on linux with wine ?? i tried for years and fail

I've been running Autoit under wine for around 8 Months now :)

@Weaponx:

I don't believe there is supposed to be a point. I think it's more of a "See if I can" type of thing.

Share this post


Link to post
Share on other sites

#18 ·  Posted

Sorry for bump, but can this output source as the line is called?

Like, script is on line 1, it shows only line 1, then it moves to 2, ect...


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Sorry for bump, but can this output source as the line is called?

Like, script is on line 1, it shows only line 1, then it moves to 2, ect...

do you want line 2 to output line 2 and line 3 to output line 3 ?

that sounds very difficult

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

here are two One-Line-Quines for Console and MsgBox

ConsoleWrite(StringReplace("ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))

MsgBox(0,'',StringReplace("MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • JSmith312
      By JSmith312
      Hello Everyone! 
      I'm attempting to create a checklist app that performs other functions. For performance, I would like to check the box, then have the button to the right enabled. After that button is pressed, the second checkbox is enabled, and ready to be checked, allowing the second button to be pressed. After the second button is pressed, the completion/exit button is enabled/shown. I have my code that currently creates the GUI, creates the checkbox, but when you check it it enables the button and the next checkbox. Can't seem to figure out a Case for GUISetOnEvent. Any assistance would be appreciated!
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> ; Below is the GUI interface _DeploymentProcess() Func _DeploymentProcess() $aStep1 = GUICreate("Deployment Process", 475, 345, 500, 175) $CBcStep1 = GUICtrlCreateCheckbox("1. Step 01.", 15, 25, 300, 25) $BTNS1 = GUICtrlCreateButton("Email 01", 365, 25, 90, 20) $CBcStep2 = GUICtrlCreateCheckbox("2. Step 02.", 15, 50, 300, 25) $BTNS2 = GUICtrlCreateButton("Email 02", 365, 50, 90, 20) GUICtrlSetState($CBcStep2, $GUI_DISABLE) GUICtrlSetState($BTNS1, $GUI_DISABLE) $CBcStep3 = GUICtrlCreateButton("Hurray! You're Complete!", 85, 276, 300, 60) GUICtrlSetState($CBcStep3, $GUI_SHOW) ; Below are the button and checkbox enables/disables. GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($aStep1) Return ; Step 1 Case $CBcStep1 If GUICtrlRead($CBcStep1) = $GUI_CHECKED Then GUICtrlSetState($BTNS1, $GUI_ENABLE) GUICtrlSetState($CBcStep2, $GUI_ENABLE) Else GUICtrlSetState($BTNS1, $GUI_DISABLE) GUICtrlSetState($CBcStep2, $GUI_DISABLE) EndIf ; Step 2 Case $CBcStep2 If GUICtrlRead($CBcStep2) = $GUI_CHECKED Then GUICtrlSetState($BTNS2, $GUI_ENABLE) GUICtrlSetState($CBcStep3, $GUI_ENABLE) Else GUICtrlSetState($BTNS2, $GUI_DISABLE) GUICtrlSetState($CBcStep3, $GUI_DISABLE) EndIf Case $CBcStep3 If GUICtrlRead($CBcStep2) = $GUI_CHECKED Then GUICtrlSetState($BTNS10, $GUI_ENABLE) GUICtrlSetState($CBcStep3, $GUI_SHOW) Else GUICtrlSetState($CBcStep3, $GUI_EVENT_CLOSE) EndIf Case $GUI_EVENT_CLOSE, $CBcStep3 #comments-end Exit EndSwitch WEnd EndFunc  
    • RoundChecker
      By RoundChecker
      Hi everyone,

      Is there a way to determine whether the script that is running, is already running, without using;
       
      If WinExists ?

      Or is there a way to use "If WinExists" to determine the script itself?

      The reason I am asking this is because if I want someone to run the .Exe I have and they rename it to whatever they want, how could I then determine in the script to check if there's already an .Exe open, or the script itself is already open?

      Should I use Class, or how do I achieve this?

      Thanks in advance.
    • svenjatzu
      By svenjatzu
      Id like to build a little helpertool for my boss in office but i dont know how to sart it.
      thats no complicated task. im working for an insurancecenter and have to search the customers in different orders and different tags.
      due to my boss is old and not really commen with pc he saves the customers without system.
      eg, customer andreas statham got an insurenca for his car then i got to search for
      andreas statham car, andreas car statham, car andreas statham, statham andreas car, statham car andreas, car statham andreass etc to find all the files from this customer in the harddrive.
      some customers also are fmiliarnamed in one file like andreas statam and monika rog are married an both got a carinsurance then i got to earch for
      andreas statham monika rog car, andreas statham monika car rog,.... this can take real long to find the right customer if i do it from hand.
      how can i realise this someone in here got an excamlple script or has any sugestion?
       
       
    • X_xkijux_x
      By X_xkijux_x
      Ok so im using this program. clarify for school. I would like to have a program that takes every word i type in microsoft word and searches on it in claryfi. is this possible. I would like to have the program not stopping me from typing more after that word. Like when i type a word it auto search it on clarify without making me stop typing and if i want to change i can do that and if im fine that word i can just keep typing and it will search after the next word. 
    • Miliardsto
      By Miliardsto
      Is this possible to make program works like in diagram? There is so much encryption methods and UDFs are they give security? If the $Address will be crypted with some encryption algorithm could be possible to get the value of $Address in easy way? Of course We know its easy too look into autoit code and get value of variable and so We dont want to anyone see $Address value - there are functions Could func1.au3, func2.au3.. be for example func1.php or other type of file? As we know .php files are unnable to see. For example func1 would be read by FileRead() and then Execute() Is this generally possible to do?
      Will it give secure?
      What do you think about? Maybe there is something wrong in this concept or missed.