Skip to content

Commit

Permalink
fix(injection): overwrite navigator.userAgent if profile is used whil…
Browse files Browse the repository at this point in the history
…e RFP is enabled; #340
  • Loading branch information
sereneblue committed May 3, 2020
1 parent 66ff003 commit 3d46292
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/lib/intercept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class Interceptor {
}
} else if (header === 'user-agent') {
if (profile) {
details.requestHeaders[i].value = profile.useragent;
details.requestHeaders[i].value = profile.navigator.userAgent;
}
} else if (header === 'accept') {
if (details.type === 'main_frame' || details.type === 'sub_frame') {
Expand Down
30 changes: 16 additions & 14 deletions src/lib/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface BrowserProfile {
platform: string | null;
plugins: object | null;
productSub: string | null;
userAgent: string;
vendor: string | null;
vendorSub: string | null;
};
Expand All @@ -27,7 +28,6 @@ export interface BrowserProfile {
availHeight: number;
deviceScaleFactor?: number;
};
useragent?: string;
osId: string;
}

Expand Down Expand Up @@ -97,7 +97,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'gzip, deflate, br',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand Down Expand Up @@ -131,6 +130,7 @@ export class Generator {
{ name: 'Native Client', filename: 'internal-nacl-plugin', description: '', version: null },
],
productSub: '20030107',
userAgent: ua,
vendor: 'Google Inc.',
vendorSub: '',
},
Expand All @@ -156,7 +156,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'gzip, deflate, br',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand All @@ -170,6 +169,7 @@ export class Generator {
platform: 'Linux aarch64',
plugins: [],
productSub: '20030107',
userAgent: ua,
vendor: 'Google Inc.',
vendorSub: '',
},
Expand Down Expand Up @@ -222,7 +222,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'gzip, deflate, br',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand All @@ -236,6 +235,7 @@ export class Generator {
platform: os.nav.platform,
plugins: [],
productSub: '20100101',
userAgent: ua,
vendor: '',
vendorSub: '',
},
Expand Down Expand Up @@ -288,7 +288,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'gzip, deflate, br',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand All @@ -302,6 +301,7 @@ export class Generator {
platform: os.nav.platform,
plugins: [],
productSub: '20100101',
userAgent: ua,
vendor: '',
vendorSub: '',
},
Expand All @@ -328,7 +328,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'gzip, deflate, br',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand All @@ -342,6 +341,7 @@ export class Generator {
platform: 'Linux aarch64',
plugins: [],
productSub: '20100101',
userAgent: ua,
vendor: '',
vendorSub: '',
},
Expand All @@ -368,7 +368,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'gzip, deflate, br',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand All @@ -382,6 +381,7 @@ export class Generator {
platform: 'Linux aarch64',
plugins: [],
productSub: '20100101',
userAgent: ua,
vendor: '',
vendorSub: '',
},
Expand Down Expand Up @@ -430,7 +430,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'gzip, deflate, br',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand Down Expand Up @@ -469,6 +468,7 @@ export class Generator {
{ name: 'Native Client', filename: 'internal-nacl-plugin', description: '', version: null },
],
productSub: '20030107',
userAgent: ua,
vendor: 'Google Inc.',
vendorSub: '',
},
Expand Down Expand Up @@ -505,6 +505,7 @@ export class Generator {
platform: 'iPhone',
plugins: [],
productSub: '20030107',
userAgent: ua,
vendor: 'Apple Computer, Inc.',
vendorSub: '',
}),
Expand All @@ -528,6 +529,7 @@ export class Generator {
platform: 'Linux armv8l',
plugins: [],
productSub: '20030107',
userAgent: ua,
vendor: 'Google Inc.',
vendorSub: '',
};
Expand All @@ -541,7 +543,6 @@ export class Generator {

return {
accept,
useragent: ua,
osId: os.id,
navigator,
screen: {
Expand Down Expand Up @@ -578,6 +579,7 @@ export class Generator {
platform: 'iPad',
plugins: [],
productSub: '20030107',
userAgent: ua,
vendor: 'Apple Computer, Inc.',
vendorSub: '',
}),
Expand All @@ -601,6 +603,7 @@ export class Generator {
platform: 'Linux armv8l',
plugins: [],
productSub: '20030107',
userAgent: ua,
vendor: 'Google Inc.',
vendorSub: '',
};
Expand All @@ -614,7 +617,6 @@ export class Generator {

return {
accept,
useragent: ua,
osId: os.id,
navigator,
screen: {
Expand Down Expand Up @@ -653,7 +655,6 @@ export class Generator {
encodingHTTP: 'gzip',
encodingHTTPS: 'gzip, deflate',
},
useragent: `Mozilla/5.0 (${os.nav.oscpu.split(';')[0]}; WOW64; Trident/7.0; rv:11.0) like Gecko`,
osId: os.id,
navigator: {
appMinorVersion: '0',
Expand All @@ -667,6 +668,7 @@ export class Generator {
platform: 'Win32',
plugins: null,
productSub: null,
userAgent: `Mozilla/5.0 (${os.nav.oscpu.split(';')[0]}; WOW64; Trident/7.0; rv:11.0) like Gecko`,
vendor: '',
vendorSub: null,
},
Expand All @@ -690,7 +692,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'br, gzip, deflate',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand Down Expand Up @@ -720,6 +721,7 @@ export class Generator {
platform: 'MacIntel',
plugins: [{ name: 'WebKit built-in PDF', filename: '', description: '', version: null }],
productSub: '20030107',
userAgent: ua,
vendor: 'Apple Computer, Inc.',
vendorSub: '',
},
Expand All @@ -745,7 +747,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'br, gzip, deflate',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand All @@ -759,6 +760,7 @@ export class Generator {
platform: 'iPhone',
plugins: [],
productSub: '20030107',
userAgent: ua,
vendor: 'Apple Computer, Inc.',
vendorSub: '',
},
Expand All @@ -785,7 +787,6 @@ export class Generator {
encodingHTTP: 'gzip, deflate',
encodingHTTPS: 'br, gzip, deflate',
},
useragent: ua,
osId: os.id,
navigator: {
appMinorVersion: null,
Expand All @@ -799,6 +800,7 @@ export class Generator {
platform: 'iPad',
plugins: [],
productSub: '20030107',
userAgent: ua,
vendor: 'Apple Computer, Inc.',
vendorSub: '',
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/spoof/navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
{ obj: 'window.navigator', prop: 'platform', value: '' },
{ obj: 'window.navigator', prop: 'plugins', value: '' },
{ obj: 'window.navigator', prop: 'productSub', value: '' },
{ obj: 'window.navigator', prop: 'userAgent', value: '' },
{ obj: 'window.navigator', prop: 'vendor', value: '' },
{ obj: 'window.navigator', prop: 'vendorSub', value: '' },
],
Expand Down

0 comments on commit 3d46292

Please sign in to comment.