Decoder
和 Encoding
类中的 GetChars
方法以及 Encoder
和 Encoding
类中的 GetBytes
方法在内部对字符数组和字节数组执行指针运算,以将字符范围转换为字节数范围,反之亦然。
out.println("x = " + encoder.encodeForJavaScript(input) + ";");
...
unichar ellipsis = 0x2026;
NSString *myString = [NSString stringWithFormat:@"My Test String%C", ellipsis];
NSData *asciiData = [myString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *asciiString = [[NSString alloc] initWithData:asciiData encoding:NSASCIIStringEncoding];
NSLog(@"Original: %@ (length %d)", myString, [myString length]);
NSLog(@"Best-fit-mapped: %@ (length %d)", asciiString, [asciiString length]);
// output:
// Original: My Test String... (length 15)
// Best-fit-mapped: My Test String... (length 17)
...
...
let ellipsis = 0x2026;
let myString = NSString(format:"My Test String %C", ellipsis)
let asciiData = myString.dataUsingEncoding(NSASCIIStringEncoding, allowLossyConversion:true)
let asciiString = NSString(data:asciiData!, encoding:NSASCIIStringEncoding)
NSLog("Original: %@ (length %d)", myString, myString.length)
NSLog("Best-fit-mapped: %@ (length %d)", asciiString!, asciiString!.length)
// output:
// Original: My Test String ... (length 16)
// Best-fit-mapped: My Test String ... (length 18)
...
MAX_PATH
字节的长度,但是您应该逐一检查每一个函数的文档。如果缓冲区大小不足以存储处理的结果,那么就会发生 buffer overflow。
char *createOutputDirectory(char *name) {
char outputDirectoryName[128];
if (getCurrentDirectory(128, outputDirectoryName) == 0) {
return null;
}
if (!PathAppend(outputDirectoryName, "output")) {
return null;
}
if (!PathAppend(outputDirectoryName, name)) {
return null;
}
if (SHCreateDirectoryEx(NULL, outputDirectoryName, NULL)
!= ERROR_SUCCESS) {
return null;
}
return StrDup(outputDirectoryName);
}
output\<name>
" 的目录,并且返回了一个同样名称的堆分配副本。对于大多数当前目录和名称参数的值来说,该函数都能够正常工作。但是,如果 name
参数特别长,那么第二个对 PathAppend()
的调用可能会溢出 outputDirectoryName
缓冲区,因为该缓冲区比 MAX_PATH
字节小。umask()
指定的掩码常常很容易与 chmod()
的参数混淆。umask()
man page 以错误的指令开始:chmod()
的用法,这种情况下,由用户提供的参数指定在特定文件上启用的位数,但事实上 umask()
的行为恰恰相反: umask()
将 umask 设为 ~mask & 0777
。umask()
man page 接下来描述了 umask()
的正确使用方法:open()
使用 umask 为新建文件设置初始文件权限。 具体而言,它会关闭 umask 从 mode 参数传递到 open(2)
的权限(例如,umask 的通用默认值 022 会导致以权限 0666 & ~022 = 0644 = rw-r--r-- 创建新文件,而在正常情况下,mode 应该为 0666)。”
...
struct stat output;
int ret = stat(aFilePath, &output);
// error handling omitted for this example
struct timespec accessTime = output.st_atime;
...
umask()
指定的掩码常常很容易与 chmod()
的参数混淆。umask()
man page 以错误的指令开始:chmod()
的用法,这种情况下,由用户提供的参数指定在特定文件上启用的位数,但事实上 umask()
的行为恰恰相反:umask()
将 umask 设为 ~mask & 0777
。umask()
man page 接下来描述了 umask()
的正确使用方法:transactionId
写入应用程序 Documents 目录下的一个临时文件:
...
//get the documents directory:
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
//make a file name to write the data to using the documents directory:
let fileName = NSString(format:"%@/tmp_activeTrans.txt", documentsPath)
// write data to the file
let transactionId = "TransactionId=12341234"
transactionId.writeToFile(fileName, atomically:true)
...
posted
对象。FileUpload
属于类型 System.Web.UI.HtmlControls.HtmlInputFile
。
HttpPostedFile posted = FileUpload.PostedFile;
@Controller
public class MyFormController {
...
@RequestMapping("/test")
public String uploadFile (org.springframework.web.multipart.MultipartFile file) {
...
} ...
}
<?php
$udir = 'upload/'; // Relative path under Web root
$ufile = $udir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $ufile)) {
echo "Valid upload received\n";
} else {
echo "Invalid upload rejected\n";
} ?>
from django.core.files.storage import default_storage
from django.core.files.base import File
...
def handle_upload(request):
files = request.FILES
for f in files.values():
path = default_storage.save('upload/', File(f))
...
file
的 <input>
标签表示程序接受文件上传。
<input type="file">
root
权限运行的程序已经造成了无数的 Unix 安全灾难。仔细检查您的程序授权是否会引发安全问题十分必要,同样重要的是,对那些授予了权限的应用程序,应及时撤销其权限并返回至未授权状态,把因忽略漏洞而引发的破坏控制到最小。root
用户切换到另外一个用户时,这种差异会尤其明显。 root
权限运行,信号处理程序或者子进程将会以 Root 权限运行。因此,攻击者有可能利用这个提高的权限来进行更严重的破坏。root
权限运行的程序已导致了无数的 Unix 安全灾难。您必须仔细审查特权程序是否存在各种安全问题,但同样重要的是,特权程序应尽快恢复到非特权状态,以限制被忽略的漏洞可能造成的损害。root
用户转换到另一个非 root 用户,这些不一致尤为明显。root
身份运行,则信号处理程序或子流程将以 root 权限运行。攻击者可能会利用这些提升的权限进行进一步的破坏。root
权限运行的程序已经造成了无数的 Unix 安全灾难。 仔细检查您的程序授权是否会引发安全问题十分必要,同样重要的是,对那些授予了权限的程序,应及时撤销其权限并返回至未授权状态,将因忽略漏洞而引发的损害控制到最小。root
用户切换到另外一个用户时,这种差异会尤其明显。root
权限运行时,如果触发某一个信号或执行子进程,则信号处理程序或者子进程将会以 root 权限运行。 因此,攻击者有可能利用这些提高的权限来进行更严重的破坏。root
权限运行的程序已经造成了无数的 Unix 安全灾难。仔细检查您的程序授权是否会引发安全问题十分必要,同样重要的是,对那些授予了权限的应用程序,应及时撤销其权限并返回至未授权状态,把因忽略漏洞而引发的破坏控制到最小。root
用户切换到另外一个用户时,这种差异会尤其明显。root
权限运行,信号处理程序或者子进程将会以 Root 权限运行。因此,攻击者有可能利用这个提高的权限来进行更严重的破坏。sun.misc.Unsafe
中的功能。此类中的所有功能本质上均不安全,只能通过反射进行访问。sun.misc.Unsafe
类用于执行不安全的低级操作,不适合开发人员使用。Unsafe
类只能通过受信任代码获取,且通常通过反射获取,因为其可用来破坏系统或手动分配堆内存,如果处理不当,可能会对系统产生不利影响。必须仔细检查和测试与 sun.misc.Unsafe
相关的所有功能,确保不出现错误。Value Stack
上下文中计算 EL 表达式。允许根据 Value Stack
计算未经验证的表达式,这将使攻击者有权修改系统变量或执行任意代码。
OgnlContext ctx = new OgnlContext();
String expression = request.getParameter("input");
Object expr = Ognl.parseExpression(expression);
Object value = Ognl.getValue(expr, ctx, root);
System.out.println("Value: " + value);
(#rt = @java.lang.Runtime@getRuntime(),#rt.exec("calc.exe"))
%{expr}
)。控制第一次计算结果的攻击者可能会控制要在第二次 OGNL 计算中计算的表达式,并注入任意 OGNL 表达式。redirectAction
结果可计算其参数两次。在这种情况下,攻击者可以通过提供 redirect
请求参数,控制 actionName
参数中强制 OGNL 表达式的结果。
...
<action name="index" class="com.acme.MyAction">
<result type="redirectAction">
<param name="actionName">${#parameters['redirect']}</param>
<param name="namespace">/foo</param>
</result>
</action>
...
%{#parameters['redirect']}
表达式,该表达式返回的用户控制字符串将作为 OGNL 表达式进行计算,从而允许攻击者计算任意 OGNL 表达式。execute()
以外的方法。如果启用“动态方法调用”,可在操作 URL 中使用 !
(bang) 字符或 method:
前缀,以在操作中调用任何公共方法。在 Struts 2 版本 2.3.20
中,先前基于反映调用替代方法的机制将替换为使用 OGNL,这样攻击者将可以提供恶意 OGNL 表达式而不是替代方法名称。debug
请求参数触发:console
将弹出 OGNL 评估控制台,允许开发人员对服务器上的任意 OGNL 表达式进行评估。command
将允许开发人员提交任意 OGNL 表达式,以使用请求参数 expression
进行评估。xml
可将参数、上下文、会话和值堆栈转储为一个 XML 文档。browser
可将参数、上下文、会话和值堆栈转储在一个可浏览的 HTML 文档中。dest
请求参数中解析的 URL。
...
DATA: str_dest TYPE c.
str_dest = request->get_form_field( 'dest' ).
response->redirect( str_dest ).
...
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数中读取的 URL。
...
var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
var strDest:String = String(params["dest"]);
host.updateLocation(strDest);
...
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。PageReference
对象,其中包含来自 dest
请求参数的 URL。
public PageReference pageAction() {
...
PageReference ref = ApexPages.currentPage();
Map<String,String> params = ref.getParameters();
return new PageReference(params.get('dest'));
}
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数中解析的 URL。
String redirect = Request["dest"];
Response.Redirect(redirect);
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数解析的 URL。
...
final server = await HttpServer.bind(host, port);
await for (HttpRequest request in server) {
final response = request.response;
final headers = request.headers;
final strDest = headers.value('strDest');
response.headers.contentType = ContentType.text;
response.redirect(Uri.parse(strDest!));
await response.close();
}
...
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数解析的 URL。
...
strDest := r.Form.Get("dest")
http.Redirect(w, r, strDest, http.StatusSeeOther)
...
Example 1
中的代码就会将浏览器重定向到 "http://www.wilyhacker.com"。dest
请求参数解析的 URL。
<end-state id="redirectView" view="externalRedirect:#{requestParameters.dest}" />
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数中读取的 URL。
...
strDest = form.dest.value;
window.open(strDest,"myresults");
...
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数中解析的 URL。
<%
...
$strDest = $_GET["dest"];
header("Location: " . $strDest);
...
%>
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数解析的 URL。
...
-- Assume QUERY_STRING looks like dest=http://www.wilyhacker.com
dest := SUBSTR(OWA_UTIL.get_cgi_env('QUERY_STRING'), 6);
OWA_UTIL.redirect_url('dest');
...
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数中解析的 URL。
...
strDest = request.field("dest")
redirect(strDest)
...
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数中解析的 URL:
...
str_dest = req.params['dest']
...
res = Rack::Response.new
...
res.redirect("http://#{dest}")
...
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。dest
请求参数中解析的 URL。
def myAction = Action { implicit request =>
...
request.getQueryString("dest") match {
case Some(location) => Redirect(location)
case None => Ok("No url found!")
}
...
}
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。requestToLoad
来指向原始 URL 的“dest”参数(如果存在该参数,如果不存在则指向使用 http://
方案的原始 URL),并最终在 WKWebView 内加载此请求:
...
let requestToLoad : String
...
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
...
if let urlComponents = NSURLComponents(URL: url, resolvingAgainstBaseURL: false) {
if let queryItems = urlComponents.queryItems as? [NSURLQueryItem]{
for queryItem in queryItems {
if queryItem.name == "dest" {
if let value = queryItem.value {
request = NSURLRequest(URL:NSURL(string:value))
requestToLoad = request
break
}
}
}
}
if requestToLoad == nil {
urlComponents.scheme = "http"
requestToLoad = NSURLRequest(URL:urlComponents.URL)
}
}
...
}
...
...
let webView : WKWebView
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
webView.loadRequest(appDelegate.requestToLoad)
...
Example 1
中的代码会尝试在 WKWebView 中请求并加载“http://www.wilyhacker.com”。dest
请求参数中解析的 URL。
...
strDest = Request.Form('dest')
HyperLink.NavigateTo strDest
...
Example 1
中的代码就会将浏览器重定向到“http://www.wilyhacker.com”。
...
var fs:FileStream = new FileStream();
fs.open(new File("config.properties"), FileMode.READ);
var password:String = fs.readMultiByte(fs.bytesAvailable, File.systemCharset);
URLRequestDefaults.setLoginCredentialsForHost(hostname, usr, password);
...
password
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
string password = regKey.GetValue(passKey).ToString());
NetworkCredential netCred =
new NetworkCredential(username,password,domain);
...
password
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
RegQueryValueEx(hkey,TEXT(.SQLPWD.),NULL,
NULL,(LPBYTE)password, &size);
rc = SQLConnect(*hdbc, server, SQL_NTS, uid,
SQL_NTS, password, SQL_NTS);
...
password
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
01 RECORD.
05 UID PIC X(10).
05 PASSWORD PIC X(10).
...
EXEC CICS
READ
FILE('CFG')
INTO(RECORD)
RIDFLD(ACCTNO)
...
END-EXEC.
EXEC SQL
CONNECT :UID
IDENTIFIED BY :PASSWORD
AT :MYCONN
USING :MYSERVER
END-EXEC.
...
CFG
具有访问权限的人都能读取密码值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
<cfquery name = "GetCredentials" dataSource = "master">
SELECT Username, Password
FROM Credentials
WHERE DataSource="users"
</cfquery>
...
<cfquery name = "GetSSNs" dataSource = "users"
username = "#Username#" password = "#Password#">
SELECT SSN
FROM Users
</cfquery>
...
master
表具有访问权限的人都能读取 Username
和 Password
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
file, _ := os.Open("config.json")
decoder := json.NewDecoder(file)
decoder.Decode(&values)
request.SetBasicAuth(values.Username, values.Password)
...
values.Password
中的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
Properties prop = new Properties();
prop.load(new FileInputStream("config.properties"));
String password = prop.getProperty("password");
DriverManager.getConnection(url, usr, password);
...
password
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
String username = credentials[0];
String password = credentials[1];
handler.proceed(username, password);
}
});
...
...
obj = new XMLHttpRequest();
obj.open('GET','/fetchusers.jsp?id='+form.id.value,'true','scott','tiger');
...
plist
文件读取密码,然后使用该密码解压缩受密码保护的文件。
...
NSDictionary *dict= [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Config" ofType:@"plist"]];
NSString *password = [dict valueForKey:@"password"];
[SSZipArchive unzipFileAtPath:zipPath toDestination:destPath overwrite:TRUE password:password error:&error];
...
...
$props = file('config.properties', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$password = $props[0];
$link = mysql_connect($url, $usr, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
...
password
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
ip_address := OWA_SEC.get_client_ip;
IF ((OWA_SEC.get_user_id = 'scott') AND
(OWA_SEC.get_password = 'tiger') AND
(ip_address(1) = 144) and (ip_address(2) = 25)) THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
...
...
props = os.open('config.properties')
password = props[0]
link = MySQLdb.connect (host = "localhost",
user = "testuser",
passwd = password,
db = "test")
...
password
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
require 'pg'
...
passwd = ENV['PASSWD']
...
conn = PG::Connection.new(:dbname => "myApp_production", :user => username, :password => passwd, :sslmode => 'require')
PASSWD
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
val prop = new Properties()
prop.load(new FileInputStream("config.properties"))
val password = prop.getProperty("password")
DriverManager.getConnection(url, usr, password)
...
config.properties
具有访问权限的人都能读取password
.的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。plist
文件读取密码,然后使用该密码解压缩受密码保护的文件。
...
var myDict: NSDictionary?
if let path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist") {
myDict = NSDictionary(contentsOfFile: path)
}
if let dict = myDict {
zipArchive.unzipOpenFile(zipPath, password:dict["password"])
}
...
...
Private Declare Function GetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long
...
Dim password As String
...
password = GetPrivateProfileString("MyApp", "Password", _
"", value, Len(value), _
App.Path & "\" & "Config.ini")
...
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=" & password &";"
...
password
的值。任何心怀不轨的雇员可以利用手中掌握的信息访问权限入侵系统。
...
password = ''.
...
...
URLRequestDefaults.setLoginCredentialsForHost(hostname, "scott", "");
...
Example 1
中的代码指示为用户帐户“scott”配置了一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
var storedPassword:String = "";
var temp:String;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(storedPassword.equals(userPassword))
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能取得存储的密码,攻击者只需向 userPassword
提供一个空字符串,就能轻松绕过密码检查。
...
HttpRequest req = new HttpRequest();
req.setClientCertificate('mycert', '');
...
...
NetworkCredential netCred = new NetworkCredential("scott", "", domain);
...
Example 1
中的代码成功执行,则表明网络凭据登录名“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
string storedPassword = "";
string temp;
if ((temp = ReadPassword(storedPassword)) != null) {
storedPassword = temp;
}
if(storedPassword.Equals(userPassword))
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能取得存储的密码,攻击者只需向 userPassword
提供一个空字符串,就能轻松绕过密码检查。
...
rc = SQLConnect(*hdbc, server, SQL_NTS, "scott", SQL_NTS, "", SQL_NTS);
...
Example 1
中的代码成功执行,则表明数据库用户帐户“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
char *stored_password = "";
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password))
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能取得存储的密码,攻击者只需向 user_password
提供一个空字符串,就能轻松绕过密码检查。
...
<cfquery name = "GetSSNs" dataSource = "users"
username = "scott" password = "">
SELECT SSN
FROM Users
</cfquery>
...
Example 1
中的代码成功执行,则表明数据库用户帐户“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
var password = "";
var temp;
if ((temp = readPassword()) != null) {
password = temp;
}
if(password == userPassword()) {
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能提取存储的密码,攻击者只需为 userPassword
提供一个空字符串,就能轻松绕过密码检查。
...
response.SetBasicAuth(usrName, "")
...
...
DriverManager.getConnection(url, "scott", "");
...
Example 1
中的代码成功执行,则表明数据库用户帐户“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
String storedPassword = "";
String temp;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(storedPassword.equals(userPassword))
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能取得存储的密码,攻击者只需向 userPassword
提供一个空字符串,就能轻松绕过密码检查。
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
String username = "";
String password = "";
if (handler.useHttpAuthUsernamePassword()) {
String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
username = credentials[0];
password = credentials[1];
}
handler.proceed(username, password);
}
});
...
Example 2
类似,如果 useHttpAuthUsernamePassword()
返回 false
,攻击者就可以通过提供空密码来查看受保护页面。
...
obj = new XMLHttpRequest();
obj.open('GET','/fetchusers.jsp?id='+form.id.value,'true','scott','');
...
{
...
"password" : ""
...
}
...
rc = SQLConnect(*hdbc, server, SQL_NTS, "scott", SQL_NTS, "", SQL_NTS);
...
Example 1
中的代码成功执行,则表明数据库用户帐户“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
NSString *stored_password = "";
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password)) {
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能取得存储的密码,攻击者只需向 user_password
提供一个空字符串,就能轻松绕过密码检查。
<?php
...
$connection = mysql_connect($host, 'scott', '');
...
?>
DECLARE
password VARCHAR(20);
BEGIN
password := "";
END;
...
db = mysql.connect("localhost","scott","","mydb")
...
...
conn = Mysql.new(database_host, "scott", "", databasename);
...
Example 1
中的代码成功执行,则表明数据库用户帐户“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。""
,作为未指定任何内容时的默认值。在这种情况下,还需要确保指定正确数量的参数,以便确保密码被传递到函数。
...
ws.url(url).withAuth("john", "", WSAuthScheme.BASIC)
...
...
let password = ""
let username = "scott"
let con = DBConnect(username, password)
...
Example 1
中的代码成功执行,则表明数据库用户帐户“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
var stored_password = ""
readPassword(stored_password)
if(stored_password == user_password) {
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能取得存储的密码,攻击者只需向 user_password
提供一个空字符串,就能轻松绕过密码检查。
...
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=;"
...
Example 1
中的代码成功执行,则表明数据库用户帐户“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
password = 'tiger'.
...
...
URLRequestDefaults.setLoginCredentialsForHost(hostname, "scott", "tiger");
...
...
HttpRequest req = new HttpRequest();
req.setClientCertificate('mycert', 'tiger');
...
...
NetworkCredential netCred =
new NetworkCredential("scott", "tiger", domain);
...
...
rc = SQLConnect(*hdbc, server, SQL_NTS, "scott",
SQL_NTS, "tiger", SQL_NTS);
...
...
MOVE "scott" TO UID.
MOVE "tiger" TO PASSWORD.
EXEC SQL
CONNECT :UID
IDENTIFIED BY :PASSWORD
AT :MYCONN
USING :MYSERVER
END-EXEC.
...
...
<cfquery name = "GetSSNs" dataSource = "users"
username = "scott" password = "tiger">
SELECT SSN
FROM Users
</cfquery>
...
...
var password = "foobarbaz";
...
javap -c
命令访问已经过反汇编的代码,而这些代码中恰恰包含用户使用过的密码值。此操作的结果可能类似于Example 1
的以下内容:
javap -c ConnMngr.class
22: ldc #36; //String jdbc:mysql://ixne.com/rxsql
24: ldc #38; //String scott
26: ldc #17; //String tiger
password := "letmein"
...
response.SetBasicAuth(usrName, password)
...
DriverManager.getConnection(url, "scott", "tiger");
...
javap -c
命令访问已经过反汇编的代码,而这些代码中恰恰包含用户使用过的密码值。此操作的结果可能类似于Example 1
的以下内容:
javap -c ConnMngr.class
22: ldc #36; //String jdbc:mysql://ixne.com/rxsql
24: ldc #38; //String scott
26: ldc #17; //String tiger
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
handler.proceed("guest", "allow");
}
});
...
Example 1
类似,该代码可以正常运行,但是有权访问此代码的任何人都可以获得此密码。
...
obj = new XMLHttpRequest();
obj.open('GET','/fetchusers.jsp?id='+form.id.value,'true','scott','tiger');
...
...
{
"username":"scott"
"password":"tiger"
}
...
...
DriverManager.getConnection(url, "scott", "tiger")
...
javap -c
命令访问已经过反汇编的代码,而这些代码中恰恰包含用户使用过的密码值。此操作的结果可能类似于Example 1
的以下内容:
javap -c ConnMngr.class
22: ldc #36; //String jdbc:mysql://ixne.com/rxsql
24: ldc #38; //String scott
26: ldc #17; //String tiger
...
webview.webViewClient = object : WebViewClient() {
override fun onReceivedHttpAuthRequest( view: WebView,
handler: HttpAuthHandler, host: String, realm: String
) {
handler.proceed("guest", "allow")
}
}
...
Example 1
类似,该代码可以正常运行,但是有权访问此代码的任何人都可以获得此密码。
...
rc = SQLConnect(*hdbc, server, SQL_NTS, "scott",
SQL_NTS, "tiger", SQL_NTS);
...
...
$link = mysql_connect($url, 'scott', 'tiger');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
...
DECLARE
password VARCHAR(20);
BEGIN
password := "tiger";
END;
password = "tiger"
...
response.writeln("Password:" + password)
...
Mysql.new(URI(hostname, 'scott', 'tiger', databasename)
...
...
ws.url(url).withAuth("john", "secret", WSAuthScheme.BASIC)
...
javap -c
命令访问已经过反汇编的代码,而这些代码中恰恰包含用户使用过的密码值。此操作的结果可能类似于Example 1
的以下内容:
javap -c MyController.class
24: ldc #38; //String john
26: ldc #17; //String secret
...
let password = "secret"
let username = "scott"
let con = DBConnect(username, password)
...
示例 2:以下 ODBC 连接字符串使用了硬编码密码:
...
https://user:secretpassword@example.com
...
...
server=Server;database=Database;UID=UserName;PWD=Password;Encrypt=yes;
...
...
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=tiger;"
...
...
credential_settings:
username: scott
password: tiger
...
...
<param name="foo" class="org.jasypt.util.password.BasicPasswordEncoder">
...
</param>
...
import hashlib
def register(request):
password = request.GET['password']
username = request.GET['username']
hash = hashlib.md5(get_random_salt() + ":" + password).hexdigest()
store(username, hash)
...
require 'openssl'
def register(request)
password = request.params['password']
username = request.params['username']
salt = get_random_salt
hash = OpenSSL::Digest.digest("MD5", salt + ":" + password)
store(username, hash)
end
...
Null
密码可能会削弱安全性。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
var storedPassword:String = null;
var temp:String;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(Utils.verifyPassword(userPassword, storedPassword))
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 userPassword
提供一个 null
值,就能轻松绕过密码检查。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
string storedPassword = null;
string temp;
if ((temp = ReadPassword(storedPassword)) != null) {
storedPassword = temp;
}
if (Utils.VerifyPassword(storedPassword, userPassword)) {
// Access protected resources
...
}
...
ReadPassword()
因数据库错误或其他问题而未能检索到存储的密码,攻击者只需为 userPassword
提供一个 null
值,就能轻松绕过密码检查。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
string storedPassword = null;
string temp;
if ((temp = ReadPassword(storedPassword)) != null) {
storedPassword = temp;
}
if(Utils.VerifyPassword(storedPassword, userPassword))
// Access protected resources
...
}
...
ReadPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 userPassword
提供一个 null
值,就能轻松绕过密码检查。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
char *stored_password = NULL;
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password))
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 user_password
提供一个 null
值,就能轻松绕过密码检查。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
password,因为这会使攻击者绕过密码验证,或是表明资源受 empty password 保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
String storedPassword = null;
String temp;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(Utils.verifyPassword(userPassword, storedPassword))
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 userPassword
提供一个 null
值,就能轻松绕过密码检查。null
,并从 Android WebView 存储中读取凭据(如果服务器先前未在当前请求中拒绝这些凭据),然后使用它们设置用于查看受保护页面的身份验证。
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
String username = null;
String password = null;
if (handler.useHttpAuthUsernamePassword()) {
String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
username = credentials[0];
password = credentials[1];
}
handler.proceed(username, password);
}
});
...
Example 1
类似,如果 useHttpAuthUsernamePassword()
返回 false
,攻击者就可以通过提供 null
密码来查看受保护页面。null
密码绝非好方法。null
:
...
var password=null;
...
{
password=getPassword(user_data);
...
}
...
if(password==null){
// Assumption that the get didn't work
...
}
...
null
,因为这可能会使攻击者绕过密码验证,或是表明资源不受密码保护。null
密码。
{
...
"password" : null
...
}
null
密码。Null
密码可能会削弱安全性。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
NSString *stored_password = NULL;
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password)) {
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 user_password
提供一个 null
值,就能轻松绕过密码检查。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
<?php
...
$storedPassword = NULL;
if (($temp = getPassword()) != NULL) {
$storedPassword = $temp;
}
if(strcmp($storedPassword,$userPassword) == 0) {
// Access protected resources
...
}
...
?>
readPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 userPassword
提供一个 null
值,就能轻松绕过密码检查。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
。
DECLARE
password VARCHAR(20);
BEGIN
password := null;
END;
null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
storedPassword = NULL;
temp = getPassword()
if (temp is not None) {
storedPassword = temp;
}
if(storedPassword == userPassword) {
// Access protected resources
...
}
...
getPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 userPassword
提供一个 null
值,就能轻松绕过密码检查。nil
密码,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。nil
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
@storedPassword = nil
temp = readPassword()
storedPassword = temp unless temp.nil?
unless Utils.passwordVerified?(@userPassword, @storedPassword)
...
end
...
readPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 @userPassword
提供一个 null
值,就能轻松绕过密码检查。nil
,作为未指定任何内容时的默认值。在这种情况下,还需要确保指定正确数量的参数,以便确保密码被传递到函数。null
,因为这会使攻击者绕过密码验证,或可能表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
ws.url(url).withAuth("john", null, WSAuthScheme.BASIC)
...
null
密码。Null
密码可能会削弱安全性。nil
密码,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,同时尝试在存储的值中读取密码,并将其与用户提供的值进行比较。
...
var stored_password = nil
readPassword(stored_password)
if(stored_password == user_password) {
// Access protected resources
...
}
...
readPassword()
因数据库错误或其他问题而未能检索到存储的密码,则攻击者只需为 user_password
提供一个 null
值,就能轻松绕过密码检查。null
,因为这可能会使攻击者绕过密码验证,或是表明资源受空密码保护。null
,并使用它来连接到数据库。
...
Dim storedPassword As String
Set storedPassword = vbNullString
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=" & storedPassword &";"
...
Example 1
中的代码成功执行,则表明数据库用户帐户“scott”配置有一个空密码,攻击者可以轻松地猜测到该密码。一旦程序发布,要更新此帐户以使用非空密码,就需要对代码进行更改。
...
* Default username for FTP connection is "scott"
* Default password for FTP connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
* Default username for database connection is "scott"
* Default password for database connection is "tiger"
...
...
<!-- Default username for database connection is "scott" -->
<!-- Default password for database connection is "tiger" -->
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
-- Default username for database connection is "scott"
-- Default password for database connection is "tiger"
...
...
# Default username for database connection is "scott"
# Default password for database connection is "tiger"
...
...
#Default username for database connection is "scott"
#Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
'Default username for database connection is "scott"
'Default password for database connection is "tiger"
...