admin管理员组文章数量:1392110
im trying to spoof ExternalInteface.call("window.navigation.userAgent.toString")
to look like a electron environment using the javascript below. though it works for the browser it keeps returning this in flash: "the thing it got is Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Goanna/6.7 Firefox/115.0 Basilisk/20250220"
i cant modify the swf file since its taken from a server, which if i use my local one some login authentication breaks. the base swf runs from an electron environment and it does an update check if the electron environment is outdated. by checking its version, anything less then 1.5.3 it will show a update screen
Object.defineProperty(navigator, "userAgent", {
get: function () {
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0";
},
configurable: true
});
console.log(window.navigator.userAgent.toString());
the flash script gets the user agent like this
public static function getUserAgent() : String
{
var _loc1_:String = null;
if(ExternalInterface.available)
{
_loc1_ = ExternalInterface.call("window.navigator.userAgent.toString");
}
return _loc1_;
}
I tried a couple of things.
thought maybe the flash environment would use some other weird function calling
window.getUserAgent = function() {
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0 ";
};`
also tried directly setting the user agent
window.navigator.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0"
so im working on the web. i need to make it so the swf thinks its in a electron enviroment. it does this check using this.
public static function getUserAgent() : String
{
var _loc1_:String = null;
if(ExternalInterface.available)
{
_loc1_ = ExternalInterface.call("window.navigator.userAgent.toString");
}
return _loc1_;
}
public static function getElectronVersion() : String
{
var _loc2_:Array = null;
var _loc1_:String = getUserAgent();
if(_loc1_ != null)
{
_loc2_ = _loc1_.match(/GameVer(Dev|Stage)?\/(\d+\.\d+\.\d+)/);
if(_loc2_ != null && _loc2_.length > 0)
{
return _loc2_[_loc2_.length - 1];
}
}
return null;
}
public static function isElectronVersionIncompatible() : Boolean
{
var _loc3_:Array = null;
var _loc2_:Array = null;
var _loc4_:int = 0;
var _loc1_:String = getElectronVersion();
if(_loc1_ != null)
{
_loc3_ = _loc1_.split(".");
_loc2_ = "1.5.3".split(".");
if(_loc3_.length == _loc2_.length)
{
_loc4_ = 0;
while(_loc4_ < _loc3_.length)
{
if(_loc3_[_loc4_] < _loc2_[_loc4_])
{
return true;
}
_loc4_++;
}
return false;
}
}
return getUserAgent() != null;
}
it does this check to see if you need to update the application
if(!gMainFrame.clientInfo.df || Utility.isElectronVersionIncompatible())
{
showUpdateRequired();
return;
}
gMainFrame.clientInfo.df is just the machines id
im trying to spoof ExternalInteface.call("window.navigation.userAgent.toString")
to look like a electron environment using the javascript below. though it works for the browser it keeps returning this in flash: "the thing it got is Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Goanna/6.7 Firefox/115.0 Basilisk/20250220"
i cant modify the swf file since its taken from a server, which if i use my local one some login authentication breaks. the base swf runs from an electron environment and it does an update check if the electron environment is outdated. by checking its version, anything less then 1.5.3 it will show a update screen
Object.defineProperty(navigator, "userAgent", {
get: function () {
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0";
},
configurable: true
});
console.log(window.navigator.userAgent.toString());
the flash script gets the user agent like this
public static function getUserAgent() : String
{
var _loc1_:String = null;
if(ExternalInterface.available)
{
_loc1_ = ExternalInterface.call("window.navigator.userAgent.toString");
}
return _loc1_;
}
I tried a couple of things.
thought maybe the flash environment would use some other weird function calling
window.getUserAgent = function() {
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0 ";
};`
also tried directly setting the user agent
window.navigator.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Electron/9.0.0"
so im working on the web. i need to make it so the swf thinks its in a electron enviroment. it does this check using this.
public static function getUserAgent() : String
{
var _loc1_:String = null;
if(ExternalInterface.available)
{
_loc1_ = ExternalInterface.call("window.navigator.userAgent.toString");
}
return _loc1_;
}
public static function getElectronVersion() : String
{
var _loc2_:Array = null;
var _loc1_:String = getUserAgent();
if(_loc1_ != null)
{
_loc2_ = _loc1_.match(/GameVer(Dev|Stage)?\/(\d+\.\d+\.\d+)/);
if(_loc2_ != null && _loc2_.length > 0)
{
return _loc2_[_loc2_.length - 1];
}
}
return null;
}
public static function isElectronVersionIncompatible() : Boolean
{
var _loc3_:Array = null;
var _loc2_:Array = null;
var _loc4_:int = 0;
var _loc1_:String = getElectronVersion();
if(_loc1_ != null)
{
_loc3_ = _loc1_.split(".");
_loc2_ = "1.5.3".split(".");
if(_loc3_.length == _loc2_.length)
{
_loc4_ = 0;
while(_loc4_ < _loc3_.length)
{
if(_loc3_[_loc4_] < _loc2_[_loc4_])
{
return true;
}
_loc4_++;
}
return false;
}
}
return getUserAgent() != null;
}
it does this check to see if you need to update the application
if(!gMainFrame.clientInfo.df || Utility.isElectronVersionIncompatible())
{
showUpdateRequired();
return;
}
gMainFrame.clientInfo.df is just the machines id
Share Improve this question edited Mar 12 at 12:06 ThatonehamYT asked Mar 12 at 8:59 ThatonehamYTThatonehamYT 11 bronze badge 7 | Show 2 more comments1 Answer
Reset to default 0Had to add in about:config "general.useragent.override.localhost" to what the flash file wanted. GameVerStage/9.9.9
本文标签:
版权声明:本文标题:javascript - How to spoof Action script 3 ExternalInteface.call("window.navigation.userAgent.toString") - Stac 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744763149a2623872.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
userAgent
is read-only according to MDN. However, the browser allows to change it via the settings, so that might be an option for you until you've ported it. – Davi Commented Mar 12 at 14:05