Tuesday, July 25, 2017

Mac os create group command line

list group.

dscacheutil -q group
sudo dseditgroup -o edit -a $username_to_add -t user admin

Mac group:

sudo dscl . -create /Groups/groupname
sudo dscl . –create /Groups/groupname name groupname
sudo dscl . –create /Groups/groupname gid   groupid
sudo dscl . –create /Groups/groupname GroupMembership usershorname


list group members

dscacheutil -q group -a name pam_idq

sudo dscl . –delete /Groups/groupname GroupMemebership usershorname

sudo dscl . –delete /Groups/groupname

Friday, July 14, 2017

fiddler capture java application traffic

Create a keystore containing the fiddler certificate and use it:
keytool -importcert -file " fiddlerroot.cer" -keystore " fiddler.jks" -alias "fiddler"


java -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888 -Dhttps.proxyPort=8888 -Dhttps.proxyHost=127.0.0.1 -Djavax.net.ssl.trustStore=<path to FiddlerKeystore> -Djavax.net.ssl.trustStorePassword=<password> -jar test.jar

If you use third party HTTP libraries, you need to set the connection proxies. Example with Apache Commons HttpClient:

HttpClient httpClient = new HttpClient();

httpClient.getHostConfiguration().setProxy("localhost", 8888);

Tuesday, July 11, 2017

Update MSI property in C# programaticaly

To update MSI property with C#,
Added reference for  Microsoft.Deployment.WindowsInstaller.dll

The PropertyTable not include default value is null Propery, we can not update the value, if not in property table, we could insert the property.


using Microsoft.Deployment.WindowsInstaller;
             
                bool isProertyExits = false ;
                using (Database msi = new Database(msiFileName, DatabaseOpenMode.Transact))
                {
                   
                     using (var view = msi.OpenView(msi.Tables["Property"].SqlSelectString))
                     {
                         view.Execute();
                         Record record = view.Fetch();                                                
                         while (record != null)
                         {
                             
                                 if (record.GetString(1) ==  ProertyName)
                                 {
                                     record.SetString("Value",  ProertyValue);
                                     view.Modify(ViewModifyMode.Assign, record);
                                     msi.Commit();
                                     isProertyExits = true;
                                 }
                           
                             record = view.Fetch();
                         }
                     }

                     //If not find
                     if (!isProertyExits) {
                         using (var view = msi.OpenView(msi.Tables["Property"].SqlInsertString))
                        {
                            foreach (var item in properties)
                            {
                               
                                   Record missingRecord = msi.CreateRecord(2);
                                   missingRecord.SetString(1, ProertyName);
                                   missingRecord.SetString(2, ProertyValue);
                                    view.Execute(missingRecord);
                                   msi.Commit();
                             
                            }
                         }
                     }
                }