package { import flash.display.Sprite; import flash.external.ExternalInterface; public class XSSTest extends Sprite { public function XSSTest() { var jsFunction:String = loaderInfo.parameters.jsFunction; var param:String = "abc"; ExternalInterface.call(jsFunction, param); } } }
public function XSSTest() { var param:String = loaderInfo.parameters.param; ExternalInterface.call("console.log", param); }
try { __flash__toXML(console.log("good" )) ; } catch (e) { "<undefined/>"; }
try { __flash__toXML(console.log("\\" ));alert(/XSS/);}catch(e){} //")) ; } catch (e) { "<undefined/>"; }
try { document.getElementById("XSSTest" ).SetReturnValue(__flash__toXML(alert( null)) ); } catch (e) { document.getElementById("XSSTest" ).SetReturnValue("<undefined/>"); }
public static function checkJsFunctionValid(functionName:String):Boolean { var reg:RegExp = /^[a-zA-Z0-9_\.]+$/; return reg.test(functionName); } public static function checkObjectIdValid():Boolean { if (ExternalInterface.available) { var objectId:String = ExternalInterface.objectID; if (!objectId || (objectId == objectId.replace(/[^0-9a-zA-Z_]/g , ""))) return true; else return false; } return true; }
str.replace( /[\"\\]/g , function(d:String, b:*, c:*){ return '\\' + d.charCodeAt(0).toString(8); });
function __flash__arrayToXML(obj) { var s = "<array>" ; for (var i=0; i<obj.length; i++) { s += "<property id=\"" + i + "\">" + __flash__toXML(obj[i]) + "</property>"; } return s+"</array>" ; } function __flash__argumentsToXML(obj,index) { var s = "<arguments>" ; for (var i=index; i<obj.length; i++) { s += __flash__toXML(obj[i]); } return s+"</arguments>" ; } function __flash__objectToXML(obj) { var s = "<object>" ; for (var prop in obj) { s += "<property id=\"" + prop + "\">" + __flash__toXML(obj[prop]) + "</property>" ; } return s+"</object>" ; } function __flash__escapeXML(s) { return s.replace(/&/g, "&" ).replace(/</g, "<").replace(/>/g, ">" ).replace(/"/g, "" ").replace(/'/g, "'"); } function __flash__toXML(value) { var type = typeof(value); if (type == "string" ) { return "<string>" + __flash__escapeXML(value) + "</string>"; } else if (type == "undefined") { return "<undefined/>" ; } else if (type == "number") { return "<number>" + value + "</number>"; } else if (value == null) { return "<null/>" ; } else if (type == "boolean") { return value ? "<true/>" : "<false/>"; } else if (value instanceof Date) { return "<date>" + value.getTime() + "</date>"; } else if (value instanceof Array) { return __flash__arrayToXML(value); } else if (type == "object") { return __flash__objectToXML(value); } else { return "<null/>" ; //??? } } function __flash__addCallback(instance, name) { instance[name] = function () { return eval(instance.CallFunction("<invoke name=\"" +name+"\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments,0) + "</invoke>" )); } } function __flash__removeCallback(instance, name) { instance[name] = null; }