Autor Beitrag
MephistoFFF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 60

Win 7

BeitragVerfasst: Do 19.03.09 17:15 
Hallo! Im PHP gibt es eine Möglichkeit, dass man einen String so behandelt, als wäre es Sourcecode.

Nun meine Frage: Ist dies auch im Delphi möglich? Also z.B.: ich habe ein Editfeld, und trage dort "showmessage('Hallo');" ein. Delphi soll diesen String nun z.B. nach klicken eines Buttons so behandeln, als wäre es Sourcecode, also dass jetzt im Bsp. die Message "Hallo" aufpoppt.
Ich brauche das ganze natürlich nicht, um messages anzuzeigen^^.

Bin für jede Hilfe dankbar.

mfG
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 19.03.09 17:33 
geht afaik NICHT
LexXis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 170
Erhaltene Danke: 3



BeitragVerfasst: Do 19.03.09 17:37 
Wenn schon müsstest du das über Scripting regeln. Entweder für grundelegende Sachen selbst einen Interpreter basteln, oder auf fertige professionele Lösungen zurückgreifen z. B. RemObjects Pascal Script
Gewuerzgurke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Do 19.03.09 17:59 
In PHP oder z.B. auch in JavaScript geht das, weil das Scriptsprachen sind. Pascal dagegen wird kompiliert und was dabei rauskommt, siehst du, wenn du eine EXE im Editor öffnest. Was möglicher weise funktionieren würde, währe, dass man ein Eingabefeld macht, in das man dann solchen kompilierten Code eingiebt. Würde aber irgendwie niemand etwas nützen :D
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 19.03.09 18:30 
Irgendwer hat hier mal eine Funktion gepostet, die Assembler aufrufen kann. Aber da das, wie gesagt, nicht viele schreiben können, müsstest du dir einen Compiler schreiben, der aus dem eingegebenen Pascal-Skript einen Assemblercode erzeugt.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 20.03.09 12:39 
Eval ist Evil! Sowohl in PHP als auch fast allen anderen Programmiersprachen (Einschließlich JavaScript).

Die meisten Makrosprachen sind da nicht viel besser. Der kürzeste XSS-Wurm in JavaScript sind ~100 Byte. Gut, das Formatieren einer Festplatte geht mit wesentlich weniger Code (wenn man die API nutzt), aber was man immer als Risiko solcher Script-Lösungen hat, ist, dass man Tür und Tor zum System öffnet, was sicherheitstechnisch eine Katastrophe ist.

Eval sollte das Letzte sein, an was man denkt, wenn es darum geht, Benutzerdefinierbare Aktionen auszuführen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Gewuerzgurke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Fr 20.03.09 16:05 
Wie kann man denn mit JavaScript die Festplatte formatieren?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 20.03.09 16:12 
user profile iconGewuerzgurke hat folgendes geschrieben Zum zitierten Posting springen:
Wie kann man denn mit JavaScript die Festplatte formatieren?

Zum Glück geht das nicht.

_________________
Markus Kinzler.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 20.03.09 16:16 
user profile iconmkinzler hat folgendes geschrieben Zum zitierten Posting springen:
user profile iconGewuerzgurke hat folgendes geschrieben Zum zitierten Posting springen:
Wie kann man denn mit JavaScript die Festplatte formatieren?

Zum Glück geht das nicht.

IE, FileSystemObject, und mal wieder ein Exploit. Sicher, mit aktuellem SPs nicht, aber ging mal über Side Channels ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 20.03.09 16:18 
Deshalb ist es auch wichtig das Microsoft mit JScript JavaScript um solche für Webscripting wichtigen Funktionen wie Formatieren erweitert hat.

_________________
Markus Kinzler.
Gewuerzgurke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Fr 20.03.09 16:31 
Auch wenn dies nicht das Forum ist...
Ich kenne JavaScript von 'Websites' her und kenne keinen Befehl, des es erlaubt, eine Datei zu öffnen, zu löschen oder sonst was... Es könnte mit eval höchstens jemand einen Code einschleusen, der das Layout der Website bis zum Neuladen ruiniert - oder? :shock:
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 20.03.09 16:32 
Microsoft hat JacaScript um soetwas erweitert, allerdings sollte das nur für lokale Seiten möglich sein. Es gab aber schon Lücken, die es möglich machten, dies auch auf remote Seiten zu nutzen

_________________
Markus Kinzler.
Gewuerzgurke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Fr 20.03.09 16:47 
Ach Microsoft... Aber jetzt kommt im Internet Explorer immer so eine Leiste mit aktive Inhalte zulassen.
René R.Fo.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116

Win7
Delphi5 Delphi2005
BeitragVerfasst: Do 09.04.09 10:28 
Zu der Anfangsgestellten frage das geht doch!!!

If (Edit1.Text = 'Hallo') then {was du machen möchtest};
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 09.04.09 10:37 
Das ist aber nicht das, was der Threadersteller möchte. Er will direkt den Source in das Edit-Feld eingeben und nicht prüfen, was da drin steht. Und wie sowas funktioniert habe ich hier mal geschrieben (Mathe-Ausdrücke ausrechnen):

www.delphi-forum.de/....php?p=517001#517001

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Gewuerzgurke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Do 10.09.09 14:26 
Ich muss jetzt doch nochmal fragen:

Ich habe ein shortstring in dem dann z.B. steht 'Procedure1'. Dieser wird an eine Funktion übergeben, die dann eben Procedure1 aufruft. Ich wollte wissen, ob es in diesem Fall eine bessere Möglichkeit gibt als:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if (shortstring = 'Procedure1'then Procedure1;
if (shortstring = 'Procedure2'then Procedure2;
if (shortstring = 'Procedure3'then Procedure3;
(...)


Ich dachte da an eine Art Pointer auf die entsprechenden procedure..n. Ich könnte leicht realisieren, dass statt 'Procedure1' ein Pointer, also z.B. 274751, übergeben wird und dann mit einer Art goto diese procedure aufgerufen wird...

Währe so etwas denkbar?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 10.09.09 14:28 
Sicher ist das denkbar, aber mit Parametern wird es dann schwierig. ;-)
Gewuerzgurke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Do 10.09.09 14:43 
Naja, sobald man eine Änderung am Programm vornimmt, würde sich der Pointer verändern, denke ich mal...
Aber in meinem Fall steht die "Ziel-procedure" in einer DLL. Normaler Weise müsste ich die dann einbinden, etwa so:

ausblenden Delphi-Quelltext
1:
procedure Procedure1; external 'DieDll.dll';					


Dadurch, dass in der DLL dann steht exports Procedure1; werden ja alle Informationen für den Aufruf bereitgestellt, also der Name der Procedure, die Adresse und eine Möglichkeit, die Variablen zu übergeben. Währe es dadurch möglich, diese Procedure aufzurufen, ohne dass ich diese erst in meinem Programm deklarieren muss?
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Do 10.09.09 14:51 
mach doch einfach dynamische importe, und importier die funktionen erst beim aufruf.
Ist zwar nicht performant, aber die einfachste Lösung.
Gewuerzgurke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Do 10.09.09 15:08 
Nach so etwas suche ich auch... Hat jemand gerade etwas Quellcode für mich?